Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

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

tut54841492
Level 2
Level 2

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
ParitMittal
Correct answer by
Level 10
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
Løjmann
Level 5
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

ParitMittal
Correct answer by
Level 10
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

tut54841492
Level 2
Level 2

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

Løjmann
Level 5
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

ParitMittal
Level 10
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

tut54841492
Level 2
Level 2

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

ParitMittal
Level 10
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

alim92960278
Level 5
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

rajneesh_gautam
Level 5
Level 5

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

johnanish
Level 3
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