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

Adobe Analytics extension, propagate custom code to all rules

cathyc18262486
Level 2
Level 2

I have a question about defining props/evars through Custom Code in Adobe Analytics extension. Particularly, how to propagate values not only for s.t() (pageview rule), but also for s.tl() (clicks).

Example:

Site configuration

I have a site with dataLayer. When a user clicks on some button, we push an event in the dataLayer.

Adobe Launch configuration

Installed two extensions:

- Data Layer Manager

- Adobe Analytics

Adobe Analytics extension settings:

Library Management: Manage the library for me  - Checked: Make tracker globally accessible

Configure tracker using custom code:

s.usePlugins=true

s.doPlugins=function(s) {

    s.eVar10=s.getNewRepeat(30,'s_gnr');

    s.eVar11="Test";

}

/* Plugin: getNewRepeat 1.2 - Returns whether user is new or repeat */

s.getNewRepeat=new Function("d","cn",""

+"var s=this,e=new Date(),cval,sval,ct=e.getTime();d=d?d:30;cn=cn?cn:"

+"'s_nr';e.setTime(ct+d*24*60*60*1000);cval=s.c_r(cn);if(cval.length="

+"=0){s.c_w(cn,ct+'-New',e);return'New';}sval=s.split(cval,'-');if(ct"

+"-sval[0]<30*60*1000&&sval[1]=='New'){s.c_w(cn,ct+'-New',e);return'N"

+"ew';}else{s.c_w(cn,ct+'-Repeat',e);return'Repeat';}");

Execute custom code: After other setting are applied

Added two rules:

1. Pageview

OzUsyn.png

2. Button click

GeFmBT.png

*Custom code added only in Adobe Analytics extension. In action Set variables, sets only events.

When the page is loaded => the pageview tag fires with eVar10 = New, eVar11 = Test.

Click on the button => the click tag fires, but eVar's don't appear.

I tried to change fire condition for button click from dataLayer push to css selector - nothing changed.

Could you please explain, how to populate eVars with the values from Global custom code on this button click?

Do I need to add custom code with all plugins to each rule?

1 Accepted Solution
Andrey_Osadchuk
Correct answer by
Community Advisor
Community Advisor

Then it's likely because linkTrackVars is not set in the "Set Variables" action of the Button click rule. Add the following line to Custom Code of the Set Variables action:

s.linkTrackVars='eVar10,eVar11';

View solution in original post

4 Replies
Andrey_Osadchuk
Community Advisor
Community Advisor

cathyc18262486,

I suppose, your code in s.doPlugins gets overwritten by the Action "Adobe Analytics - Clear Variables". Try to temporarily delete this block from both Rules and check whether the eVars will get properly populated afterwards.

Andrey_Osadchuk
Correct answer by
Community Advisor
Community Advisor

Then it's likely because linkTrackVars is not set in the "Set Variables" action of the Button click rule. Add the following line to Custom Code of the Set Variables action:

s.linkTrackVars='eVar10,eVar11';

View solution in original post