12 Replies Latest reply on Sep 20, 2017 4:07 PM by sabahatu1546489

    Audience and URL Targeting

    sabahatu1546489 Level 1

      HI there,


      We have started using Adobe Target Premium. In terms of targeting and audience, we are struggling to find the following things. A detailed response would be much appreciated.

      1- Activate the campaign for specific IP or cookie
      2- Can URL targeting contain regular expression? I can only see URL "is", "contains", "starts with" etc options.
      3- Target campaigns for all other device types? At the moment under Audience it only says "Mobile"?



        • 1. Re: Audience and URL Targeting
          ryanr8 Adobe Employee



          There is quite a lot of ways to create targeting rules and define audiences in Target. Here are some ways to solve your specific use cases.

          1. To audience off of a visitors specific IP you can use a profile script (Target > Audiences > Profile Scripts) to store a visitors IP address as a parameter you can then define an audience off of. The profile script could also check the visitors IP against a specified range of IP addresses and return a true or false it the visitors IP matches the specified range. There's lots of flexibility here. Help has lots of info on creating profile scripts and the different variables available (Profile Script Attributes). When you create an audience that uses your profile script variable, they are found in the "visitor profile" dimension drop-down. For a specific cookie of your site you have to explicitly pass that info into Target via an mbox parameter as the browser will not send cookie info from your domain to the Target domain (*.tt.omtrdc.net). Once you are passing the cookie info as an mbox parameter or profile.parameter then you can create an audience off of that attribute.
          2. URL targeting can almost always be done without needing regex by using a combination of the available operators. There are quite robust options. However, when it's easier or preferred to use regex you can do so with a profile script. You can then apply it to an audience and use that as the activity's Target audience. Here is a sample profile script for Target that will evaluate a URL with a regex.

          if (page.path.match(/basketball\/nba\/\w+?-|football\/nfl\/\w+?-/) !== null ||

              '') {

              return true;

          } else {

              return false;


          3. When defining an audience, if you select mobile you then get sub selection options for "is mobile", "is tablet", "is mobile phone" each can be evaulated true/false so you can effectively target tablets, mobile phones and non-mobile (i.e., desktop). If you need further granlularity you can again use profile script to evalute the user agent string of your visitors and build audiences based on that profile script.

          • 2. Re: Audience and URL Targeting
            sabahatu1546489 Level 1

            Thanks for your response.

            Touching upon the targeting the cookies part. I am still struggling with it. Lets say we have a cookie "premiumUsers". This cookie gets added for all types of premium users. they take a value between 001 to 005. We only want to target the experiment for the users whose cookie value is 001, 002, or 003. i.e premiumUsers=001 or premiumUsers=002 or premiumUsers=003
            what parameter/token we can use. Normally with the following code it doesn't seem to be working


            function getCookieValue(a) {

                var b = document.cookie.match('(^|;)\\s*' + a + '\\s*=\\s*([^;]+)');

                return b ? b.pop() : '';



            var userValue = getCookieValue("premiumUsers");

            var somestring = "001, 002, 003",

                separated = somestring.split(",");


            for (var i = 0, length = separated.length; i < length; i++) {

                var chunk = separated[i];


              if(userValue == chunk){

                   return true;




            Please let me know. Many thanks

            • 3. Re: Audience and URL Targeting
              ryanr8 Adobe Employee

              I can't speak to the code sample above specifically, but once you have the cookie reading and parsing code figured out you can use the targetPageParams() function (for at.js, if using mbox.js you want to use mboxParameters() function) to turn the cookie values into key pairs that get passed to Target.


              For a cookie that relates to a visitor I'd use a "profile." parameter because that will be sticky to the visitors profile in Target (i.e., even if you don't pass it in each request Target will still remember it). So ultimately you want your targetPageParams() output to end up something like this:


              function targetPageParams() {

                return "profile.premiumUsers=001";


              Also, this code needs to be run before you call the at.js file. Alternatively, you could add it to the top of your at.js file.

              • 4. Re: Audience and URL Targeting
                sabahatu1546489 Level 1

                2 things now


                1- Would that require us to add that code to the at.js file. download it and add to the head again. Is there an alternative to that. as adding to the header delay things for us.


                2- once we add this targetPageParams() I believe "profile.premiumUsers=001" would appear under Available Tokens of Profile script? is that correct.

                • 5. Re: Audience and URL Targeting
                  ryanr8 Adobe Employee

                  1- It doesn't have to be in the at.js file itself (though adding it to the top of the at.js is usually easiest); however, it must be on the page before the at.js loads. So either way you'll need to make a change to your header I think.

                  2- Yes profile.premiumUsers will be an availalbe attribute/token in profile scripts and also available under Visitor Profile when defining audiences (though in the dropdown the "profile." isn't displayed for brevity).

                  • 6. Re: Audience and URL Targeting
                    sabahatu1546489 Level 1

                    somewhere I am still lost.


                    please correct me where I am doing wrong


                    1- I added the following script to read the cookie inside the targetPageParams() function. Please see here.



                    2- Then I go to the experience, I can see the "premiumUsers" is displayed in the dropdown of the audience.

                    3- I select that as my audience and under evaluator I put "001", click next and save


                    Now I should expect the experience to work if the user has cookie name "premiumUsers" and has value 001. unfortunately it's not working. Please let me know where I m doing wrong.

                    • 7. Re: Audience and URL Targeting
                      ryanr8 Adobe Employee

                      That code looks good. It worked for me in my sandbox site. I also see the "profile.premiumUsers" in my mbox request when viewing the network tab in the browser dev tools. I also see the premiumUsers show up in the visitor profile drop down. Your audience definition should look like this:9-19-2017 10-21-56 AM.png

                      If you aren't getting in the experience as you expected then I'd check 2 things.

                      1) is this an XT activity? So each experience has a unique audience? If it's an AB activity then your "premiumUsers=001" should be set as the activity audience in step 2.

                      2) Try with a clean visitor (private browsing tab works nice for this). You will need to make sure your visitor has the right cookie still so that Target sees that.


                      If that doesn't help perhaps you could send some screen shot of the activity setup.

                      • 8. Re: Audience and URL Targeting
                        sabahatu1546489 Level 1

                        awesome its working. I should have tried in incognito before. many thanks

                        Is there anyway we can add the targetPageParams() function through adobe target directly.

                        Making the change to at.js and adding to head section or accessing the backend files and add that manually, both would delay things at our end. Any suggestions in that regard? we basically want to do the whole thing without accessing the backend files.


                        Lastly, if using form based composer we need to run experiment on 2 urls, is the below approach the correct one. (although it doesn't give any 'or' and 'and')?




                        • 9. Re: Audience and URL Targeting
                          ryanr8 Adobe Employee

                          Great to hear!


                          So you can't use the targetPageParams() function from within Target itself. It adds parameters to the very first call to Target so anything returned by that Target request would be too late. You can however, fire an adobe.target.TrackEvent() function from custom HTML offer or custom code edited offer. You can include the JS to run your read cookie function, then send the cookie value as a profile.parameter in the adobe.target.TrackEvent () function. Something like this:


                          adobe.target.trackEvent({mbox:'profileCapture',"params": {"profile.premiumUsers":"001"}});

                          In my example I've created a new mbox called "profileCapture" something like this make it easy to distinguish that this isn't the normal mbox request (you could technically use the target-global-mbox if you wanted). Using adobe.target.trackEvent from Target served offers has caveates though. Primarily timing. Since the code comes back from Target that profile data is only going to be available to activity entry on the next page. Also, you'll have to create a Target activity just to return the read cookie code and the adobe.target.trackEvent function.


                          On adding an "OR" condition in your form test you want to enter the second url in a new line within the same statement. Adding it as a separate statment like in your screenshot will invoke an "AND" between the statements. New lines within a statement are intrepreted as "OR" conditions.

                          • 10. Re: Audience and URL Targeting
                            sabahatu1546489 Level 1

                            Hey Ryan,


                            does it mean we'll run one activity to 100% containing the code for readcookie and trackevent. and then  Another Activity (our main one) using that cookie as an audience? is it correct

                            and the code would be like this


                            • 11. Re: Audience and URL Targeting
                              ryanr8 Adobe Employee

                              Yes, that is how I'd setup it up with 2 activities. That code looks right to me.

                              • 12. Re: Audience and URL Targeting
                                sabahatu1546489 Level 1

                                sounds good. I'll give it a shot today. The only thing I am concerned about is how would we make sure the one containing readcookie function executes first?