JavaScript code that returns list of activities running on page

Avatar

Avatar
Springboard
Level 8
gaureshk3014423
Level 8

Likes

201 likes

Total Posts

168 posts

Correct reply

33 solutions
Top badges earned
Springboard
Validate 1
Contributor
Coach
Shape 10
View profile

Avatar
Springboard
Level 8
gaureshk3014423
Level 8

Likes

201 likes

Total Posts

168 posts

Correct reply

33 solutions
Top badges earned
Springboard
Validate 1
Contributor
Coach
Shape 10
View profile
gaureshk3014423
Level 8

19-12-2019

Can anyone provide me JS code that returns list of activities running on a page?

 

 

Thanks,

Gauresh kodag

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Level 2
praveshn5700477
Level 2

Likes

19 likes

Total Posts

21 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 2
praveshn5700477
Level 2

Likes

19 likes

Total Posts

21 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
praveshn5700477
Level 2

07-01-2020

Hi, Use the Below code:

<script type="text/javascript" > 
  document.addEventListener(adobe.target.event.REQUEST_SUCCEEDED, function (e) { 
    window.ttMETA= typeof(window.ttMETA)!="undefined" ? window.ttMETA : []; 
 
    var tokens=e.detail.responseTokens; 
 
    if (isEmpty(tokens)) { 
      return; 
    } 
     
    var uniqueTokens = distinct(tokens); 
 
    uniqueTokens.forEach(function(token) { 
      window.ttMETA.push({ 
        'CampaignName': token["activity.name"], 
        'CampaignId' : token["activity.id"], 
        'RecipeName': token["experience.name"], 
        'RecipeId': token["experience.id"], 
        'OfferId': token["option.id"], 
        'OfferName': token["option.name"], 
        'MboxName': e.detail.mbox}); 
      console.log(ttMETA); 
    }); 
  }); 
 
  function isEmpty(val){ 
    return (val === undefined || val == null || val.length <= 0) ? true : false; 
  } 
 
  function key(obj) { 
     return Object.keys(obj) 
    .map(function(k) { return k + "" + obj[k]; }) 
    .join(""); 
  } 
 
  function distinct(arr) { 
    var result = arr.reduce(function(acc, e) { 
      acc[key(e)] = e; 
      return acc; 
    }, {}); 
   
    return Object.keys(result) 
    .map(function(k) { return result[k]; }); 
  } 
</script>

Answers (0)