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
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Capture Activity Map Context Data

MktgCloudUser
Level 4
Level 4

Hello,

I need to capture the Activity Map "region" whenever the user clicks a link on my site but before the s.tl action is fired.  I am aware I can use Processing Rule to copy this value but I need the value client-side.  I can see the value in the EC Debugger so I know it's working properly.

I've tried the following without success:

console.log('activity map value=' + s.contextData['a.activitymap.region']);

console.log('activity map value=' + s.contextData['c.a.activitymap.region']);

console.log('activity map value' + s.ActivityMap.region);

Any thoughts on how I can get this value?

1 Accepted Solution
Gigazelle
Correct answer by
Employee
Employee

The plugins function should be doing the trick, but if not, you could use Object.watch() to determine when the contextData variable changes, then insert your code after that takes place. I found this thread on StackOverflow that might help:

javascript - Break on a change of variable value - Stack Overflow

Basically you'll want to figure out exactly when the activity map variable is populated, then you'll be able to insert your own code after that (but before the image request is sent). Bear in mind that this might require inserting code where Adobe says you shouldn't, but hopefully that isn't the case.

View solution in original post

6 Replies
pabloc82923542
Level 9
Level 9

Can you expand on what it is you are trying to accomplish?

What is the region data going to help you with?

MktgCloudUser
Level 4
Level 4

I wish to capture the same value being reported in the Experience Cloud Debugger before it is submitted via the s.tl request.

2019-02-04_10-49-51.jpg

Gigazelle
Employee
Employee

You should be able to grab the variable value if you do so inside the doPlugins() function. Could you give that a shot and let me know if that works?

MktgCloudUser
Level 4
Level 4

Gigazelle​ - nope, unfortunately that didn't work.  I tried all three in the original post inside of the doPlugins and got the following in the console (basically the same as outside of the doPlugins section):

activity map value=

activity map value=undefined

activity map value=function(e){for(var t,a=f.regionIDAttribute||"id";e&&(e=e.parentNode);){if(t=o(e,a,a,a))return t;if("BODY"==e.nodeName)return"BODY"}}

Maybe there's a different function I should be using?

Gigazelle
Correct answer by
Employee
Employee

The plugins function should be doing the trick, but if not, you could use Object.watch() to determine when the contextData variable changes, then insert your code after that takes place. I found this thread on StackOverflow that might help:

javascript - Break on a change of variable value - Stack Overflow

Basically you'll want to figure out exactly when the activity map variable is populated, then you'll be able to insert your own code after that (but before the image request is sent). Bear in mind that this might require inserting code where Adobe says you shouldn't, but hopefully that isn't the case.

View solution in original post

Willian_Z
Level 1
Level 1

Hello all,

 

I've struggled with a similar problem these days where the I wanted to capture the Activity Map's "link" property from media-sharing buttons to send it in a specific eVar in hit links through the "track outbound links" function from the analytics extension.

 

First I tried using the s.linkName in doPlugins, but its value was always "0" although in the hit, the a.activitymap.link showed the good value ("Facebook","Twitter", etc). When I tried using the s.contextData[a.activitymap.link] it also didn't work, when I put a debugger break inside the doPlugins and checked in the console, there was really nothing in the console:

Willian_Z_0-1632473674667.png

(this make me wonder if the activity map is added to the tracker (s) after doPlugins?)

 

It's when I inspected the s.linkObject that I saw that the HTML object retrieve was a link <a>, but what I needed was the "alt" attribute in the <img> tag that was inside the retrieved <a> (exactly what was shown in the activity map when inspecting the hit in the network tab).

So in my specific case I had to use this inside doPlugins:

var linkName = s.linkObject ? s.linkObject.firstElementChild.getAttribute("alt") : null;

Then I remembered that Activity Map has these configuration variables 

So, to don't depend on a specific HTML structure, I discovered a better solution that I guess will work for any case:

var linkName = s.ActivityMap.link(s.linkObject);

And then you can change ".link" with ".region".

 

I think it's odd that Activity Map automatically finds the good value, but not s.linkName, specially after this update (which is doesn't match the extension description by the way):

 

Willian_Z_1-1632474703542.png

 

Here's my current version:

Willian_Z_2-1632474807942.png

 

I hope the Adobe team will be more reactive in keeping the release dates in the documentation up to date (the version 1.8.7 of the extension is already available in Launch but there's no release note in the doc)

 

Cheers!