Expand my Community achievements bar.

Join us at Adobe Summit 2024 for the Coffee Break Q&A Live series, a unique opportunity to network with and learn from expert users, the Adobe product team, and Adobe partners in a small group, 30 minute AMA conversations.
SOLVED

Capture Activity Map Context Data

Avatar

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

Avatar

Correct answer by
Employee Advisor

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

Avatar

Community Advisor

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

What is the region data going to help you with?

Avatar

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

Avatar

Employee Advisor

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?

Avatar

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?

Avatar

Correct answer by
Employee Advisor

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.

Avatar

Level 2

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!