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

No Analytics Call Generated after adding Custom Code to Analytics Extension

Avatar

Level 1

Hi,

I have a dev site set up on adobeaemcloud.com where I am tracking page load & button click rules. We have ACDL implemented here so cmp:show & cmp:click events are triggered on page load & button click respectively.

Initially, the plugin code for getPreviousValue & others was blocking the server calls, so I added the Common Analytics extension plugin.

My Page Load  Rule - Initialising the plugins that I need, set variables & send beacon

hashaikh1198_0-1662685713992.png

Custom Code config in Adobe Analytics Extension

hashaikh1198_1-1662685786442.png

As soon as I add the code in comments (custom code config) into the function, the analytics server calls get blocked. 

hashaikh1198_2-1662685996172.png

 

However, even though I have generic plugin code as shown in the above screenshot (which was working earlier), its still blocking the server calls.

Would really appreciate any suggestions. 

 

10 Replies

Avatar

Community Advisor

1. If you're letting Launch manage the Analytics library for you, ensure that you have made the tracker globally accessible. This checkbox setting is available in the Adobe Analytics extension > Library Management > Manage the library for me > Make tracker globally accessible.

2. In Common Analytics Plugins, verify that you've enabled your 3 plugins (found in your commented code): getPercentPageViewed, getPageName, getPreviousValue.

 

If you still get the same result after performing the above 2 steps, then comment your code block by block (or line by line) till you're able to isolate the problem.

Avatar

Level 1

Hi @yuhuisg 

Please see below response.

 

1. Tracker has been made globally accessible as per your comment.

hashaikh1198_0-1662693658505.png

 

2. The plugins needed have been enabled in the Common Analytics Plugin

 

3. Pretty sure the code highlighted below is blocking the server calls. I had added that code to track previous page name.

Would you know why that blocks the server calls & if there's an alternate method to track previous page without the plugin.

PS: Cannot add Previous page name to the Datalayer

hashaikh1198_1-1662693724099.png

 

Avatar

Community Advisor

Does s.getPageName() work by itself?

In your browser console, do you see any errors when loading your page, in particular, errors that might be related to this custom code? If so, please share a screenshot of those errors.

Avatar

Level 1

Not really. I've just sent you screenshots of the errors. 

I see this error in relation to getPageName() for the Page Scroll Rule in Launch..

Failed to execute "Send Beacon" for "Page Scroll 25%" rule. e.getPageName is not a function
TypeError: e.getPageName is not a function

Custom code shown below

hashaikh1198_0-1662698011930.png

 

Avatar

Community Advisor

Thanks for the screenshots.

The error is stated right there: "e.getPageName is not a function"

So that means, for some reason, the getPageName() plugin is not available when your scroll rule fires. To see if that plugin is really absent, in your browser console, run "s.getPageName()" and see if it returns a valid result or an error. If it returns an error, then you need to enable this plugin.

Avatar

Level 1

Thanks. It does give the same error in console on executing "s.getPageName()

I've created a rule to fire on Page top & action = Initialise plugins. See below. 

You can see getPageName is ticked here. However, there are still no server calls for any Launch rules.

hashaikh1198_0-1662699036416.png

I even tried to set an action within the Page Load & Page scroll rule to initialising the plugin within the rule & it still gives the same error.

Avatar

Community Advisor

Oh! getPageName is initialised as a global function within "window", not "s". Notice the "window" in the 4th column of the Initialize action.

Try changing your code from "s.getPageName()" to just "getPageName()" or "window.getPageName()".

Avatar

Level 1

Thanks. Using just "getPageName()" worked but I also had to create a data element for the plugin as shown below & assign it to an eVar in the page load rule. 

hashaikh1198_0-1662705085178.png

 

However, when I add any of the below options (within the custom code) to get the Previous page name, I am not able to get eVar7 = Previous page name in server calls. I am testing links that open in a new tab. Assuming it should still give the previous page names for these ones.

Note: getPreviousValue() has been enabled within the plugin & we cannot create a data element for getPreviousValue(). I've also enabled p_fo which is needed for getPreviousValue()

 

Option 1:

s.pageName = getPageName();
s.eVar7 = s.getPreviousValue(s.pageName, "gpv_Page")

 

Option 2:

s.pageName = getPageName();

s.eVar4 =  getPageName();
s.eVar7 = s.getPreviousValue(s.eVar4); 

 

Option 3:

s.pageName = getPageName();

if(s.pageName){
s.eVar7 = s.getPreviousValue(s.pageName,'gpv_Page');
}  

 

Option 4:

s.pageName = getPageName();

s.eVar4 =  getPageName();

 

if(s.pageName){
s.eVar7 = s.getPreviousValue(s.eVar4);

}

hashaikh1198_4-1662705503442.png

 

 

Avatar

Community Advisor

Firstly, since you had created a data element for getPageName(), then you should use that data element instead to set your s.pageName. I.e.

s.pageName = _satellite.getVar('getPageName data element');

Anyway, I would expect that any of your 4 options would work. I wonder, if you use the above _satellite.getVar() method, will you be able to set eVar7 properly? E.g. from option 1

s.pageName =  _satellite.getVar('getPageName data element');

s.eVar7 = s.getPreviousValue(s.pageName, "gpv_Page")

Avatar

Level 1

Thanks. To clarify, I had to create a data element for getPageName() as without the data element the below code didn't work. I was not getting Page Name at all w/o the DE.

 

s.pageName = getPageName();

s.eVar4 =  getPageName();

 

I have now updated custom code to 

/* Plugin Config */
s.usePlugins=true;
s.doPlugins = s_doPlugins

function s_doPlugins(s)
{
s.eVar17 = s.getNewRepeat();
s.eVar19 = s.getTimeSinceLastVisit();
s.eVar20 = s.getVisitNum();
s.campaign = s.getQueryParam('fbclid,q');
s.eVar21 = s.getQueryParam('fbclid,q');

s.pageName = _satellite.getVar('getPageName');
s.eVar7 = s.getPreviousValue(s.pageName,'gpv_Page');
}

 

Rules:

1. Rule 1: Initialises all plugins needed on Library Loaded - Page top

2. Rule 2: Fires on an event and sets variables, no custom code added to the rule

3. Rule 3: For Scroll Depth Tracking

 

Data element:

1. getPageName 

hashaikh1198_0-1662709567936.png

 

2. Other common analytics plugin related DE

 

Still unable to get Previous page name. See function in console below

hashaikh1198_1-1662709641069.png

 

I read this thread where the issue was due to the domain & was resolved after publishing to production. As my domain for my dev environment is adobeaemcloud.com, is it possible that would be causing the issue?