Expand my Community achievements bar.

Webinar: Adobe Customer Journey Analytics Product Innovations: A Quarterly Overview. Come learn for the Adobe Analytics Product team who will be covering AJO reporting, Graph-based Stitching, guided analysis for CJA, and more!
SOLVED

ERROR ReferenceError: s is not defined

Avatar

Level 1

Hello,

 

I'm using Commanders Act as TMS for Adobe Analytics and since I moved the CMP to Didomi I got some problems with the s object which sometimes si "undefined" specially for tags on spa pages.

 

I tried to initialise it with a condition when s === "undefined" with var s = new AppMeasurement(); however it doesn't work, if I do so, I have other errors like s.apl is not a function.

 

My Adobe config tag looks like this:

- trigger container loaded:

var scriptElt2 = document.createElement("script");
scriptElt2.id = "tc_script__2";
scriptElt2.language = "javascript";
scriptElt2.src="Appmeasurement.js";
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0] || document.getElementsByTagName('script')[0].parentNode).insertBefore(scriptElt2, null);

 

My appmeasurement file is also enclosed to the tag.

 

In the same tag on Didomi event(which comes after container is loaded I have conditions for sending evars etc.

And also functions for plugins

 

So when I have a tag with s object "undefined" does it mean that the app measurement file is not available?

I put and executed the function in the console and it doesn't change anything.

 

Anyone could help?

 

Thanks

 

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

It could be that you have not implemented AppMeasurement properly. Follow the instructions at https://experienceleague.adobe.com/docs/analytics/implementation/js/overview.html?lang=en to ensure that you've implemented it correctly.

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

It could be that you have not implemented AppMeasurement properly. Follow the instructions at https://experienceleague.adobe.com/docs/analytics/implementation/js/overview.html?lang=en to ensure that you've implemented it correctly.

Avatar

Community Advisor

Based on your images, you are using the old "direct in code" method of tagging, which most people don't use any more....

 

This is totally dependent on the order of operation that all those script files run, and without doing a deep dive into the implementation, I am not sure we would be able to support this....

 

The error itself "s is not defined" indicates that your AppMeasurement.js file either failed to load completely, or loaded after the code in tc_Eurofil_11.js ran.... 

 

Given you are adding the AppMeasurement.js file to the site via script (instead of just adding it to the head of the document), means that even your base implementation is a custom solution....

 

Unfortunately, I think you will have to deep dive this on your own... check the network panel, does AppMeasurement.js load? Does it load before or after tc_Eurofil_11.js? Try using your developer console to add some breakpoints in the files, check what is and isn't loaded at the time some code is supposed to trigger..

 

The problem with custom implementations is that it's very hard for other people to help you, as we don't know anything about what you've done or how it's supposed to work.