Expand my Community achievements bar.

Applications for the 2024 Adobe Target Community Mentorship Program are open! Click to the right to learn more about participating as either an Aspirant, to professionally level up with a new Certification, or as a Mentor, to share your Adobe Target expertise and inspire through your leadership! Submit your application today.
SOLVED

How can i get the ID or title of the current exprience in the page where is tested?

Avatar

Former Community Member

For example , I make Experiences A and Experiences B , and deploy on my site, now I want get the current experience name or id  with javascript , how should i do ?

thanks a lot !

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi ,

As suggested by Thomas, You can use the pass the below code in custom code section of each experience variation of the test to fetch the experience ID etc.

<script type="text/javascript">

var sCampaignName='${campaign.name}';

var sExperienceName = '${campaign.recipe.name}';

var scampId='${campaign.id}';

var sExpId=${campaign.recipe.id}'

alert("Your Campaign name is " + '${campaign.name}' + " :Your Experience name is "+ '${campaign.recipe.name}'+" :Your campaign Id is "+'${campaign.id}' +" :Your Experience ID is "+ '${campaign.recipe.id}' );

</script>

Regards

Parit Mittal

View solution in original post

11 Replies

Avatar

Level 5

Hi,

You can print those information by writing {campaign.name} or {campaign.id} as part of the HTML/JS returned in an experiment. See the full list of parameters here: Useful Variables, Profiles, Parameters, and Methods

/Løjmann

Avatar

Correct answer by
Level 10

Hi ,

As suggested by Thomas, You can use the pass the below code in custom code section of each experience variation of the test to fetch the experience ID etc.

<script type="text/javascript">

var sCampaignName='${campaign.name}';

var sExperienceName = '${campaign.recipe.name}';

var scampId='${campaign.id}';

var sExpId=${campaign.recipe.id}'

alert("Your Campaign name is " + '${campaign.name}' + " :Your Experience name is "+ '${campaign.recipe.name}'+" :Your campaign Id is "+'${campaign.id}' +" :Your Experience ID is "+ '${campaign.recipe.id}' );

</script>

Regards

Parit Mittal

Avatar

Former Community Member

thanks everyone !

Now anther question: Now I know the info (id ,name etc) of one experience , how can I get the offers or the actions  of the experience with javascript ?

LøjmannParitMittal

Avatar

Level 5

What do you think of here? Do you want the offer name and conversion measure, into JS?

As far as I know, you can't get the conversion points in (that is taking measure server-side), the only campaign related variables you can fetch are:

  • campaign.name
  • campaign.id
  • campaign.recipe.name
  • campaign.recipe.id
  • offer.name
  • offer.id

/Løjmann

Avatar

Level 10

Hi ,

you can use below to get the offers for each experience with Javascript.

  • ${offer.name}
  • ${offer.id}

Also, to measure the Action you have to set up Goals with your test. Please see the following link for more help :Goals and Settings

Avatar

Former Community Member

for example,  I make Experiences A and Experiences B ,

experience name              experience id

Experiences A                   0

Experiences B                   1

and the action of Experiences A which id is 0 is just set the background-color to white:

[{

     "actions": [{

          "property": "background-color",

          "action": "setStyle",

          "selector": "HTML > BODY > DIV:nth-of-type(1)",

          "priority": "important",

          "value": "rgba(255,255,255,1)",

          "cssSelector": "HTML > BODY > DIV:nth-of-type(1)"

      } ]

  }]

and Experiences B which id is 1 is set the background-color to black;

[{

     "actions": [{

          "property": "background-color",

          "action": "setStyle",

          "selector": "HTML > BODY > DIV:nth-of-type(1)",

          "priority": "important",

          "value": "rgba(0,0,0,1)",

          "cssSelector": "HTML > BODY > DIV:nth-of-type(1)"

      } ]

  }]

on the test page I have got the a Experience id 1 which is from my database , now  I want to get below info from the id 1:

[{

     "actions": [{

          "property": "background-color",

          "action": "setStyle",

          "selector": "HTML > BODY > DIV:nth-of-type(1)",

          "priority": "important",

          "value": "rgba(0,0,0,1)",

          "cssSelector": "HTML > BODY > DIV:nth-of-type(1)"

      } ]

  }]

how should I do ?

LøjmannParitMittal

Avatar

Level 10

Hi ,

As far as I know, you can't fetch the actions in an experience inside a test. As decribed by Løjmann you can only fetch campaign below variables using Javascript.

  • campaign.name
  • campaign.id
  • campaign.recipe.name
  • campaign.recipe.id
  • offer.name
  • offer.id

Regards

Parit Mittal

Avatar

Level 5

Hi Parit,

is this supposed output to the console when a test page is loaded? If so, I don't see anything at.

I added this to the Custom Code section of Exp. A and Exp. B.

Also, which cookie ties a visitor to a specific experience and prevents them from being part of Exp. A and Exp. B.?

Ali

Avatar

Community Advisor

Hi there,

If I am reading it correctly, you are looking for Experience Targeting where Experience Audiences are derived by a value that you are extratcing from your dataabse. In that case, flow will look like:

1. Data (for your example, this will be ID 0 or 1) on the basis of which experience needs to be selected.

2. Pass this data using targetPageParams to Global mbox call (say expId=0 and expId=1)

3. Create Audiences on the basis of passed parameter and different values.

4. Use these audiences in an Experience Targeting activity where offer-code just returns a JSON object as you have stated below.

Let me know if my interpretation was wrong,

Regards,

Rajneesh

Avatar

Level 3

Hey alim92960278,

This will not print anything into the console unless you explicitly tell it to. You may want to instead console.log it like this

<script>

console.log("Your Campaign name is " + '${campaign.name}');
console.log("Your Experience name is "+ '${campaign.recipe.name}');

console.log("Your Campaign ID is "+ '${campaign.id}');

console.log("Your Experience ID is "+ '${campaign.recipe.id}');

</script>

Also you may want to look at this documentation which Adobe provides on what useful parameters you can use found here: Useful Variables, Profiles, Parameters, and Methods

Target Troubleshooting - YouTube at 12:00 mins

Important: Make sure you also enable the response tokens if you need this to show up:

response_tokens.jpg