Skip to main content
Level 2
Jul 1, 2019 10:19 AM UTC
Solved

Adobe Analytics extension, propagate custom code to all rules

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Andrey_Osadchuk
Andrey_OsadchukAccepted solution
Level 10
Jul 1, 2019 3:24 PM UTC

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';

4 replies

Andrey_Osadchuk
Level 10
Jul 1, 2019 12:50 PM UTC

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.

Translate
Level 2
Jul 1, 2019 3:12 PM UTC

The same result

Translate
Andrey_Osadchuk
Andrey_OsadchukAccepted solution
Level 10
Jul 1, 2019 3:24 PM UTC

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';

Translate
Level 2
Jul 1, 2019 4:28 PM UTC

Thank you Andrey! It works

Translate