Expand my Community achievements bar.

Join us for the next Community Q&A Coffee Break on Tuesday April 23, 2024 with Eric Matisoff, Principal Evangelist, Analytics & Data Science, who will join us to discuss all the big news and announcements from Summit 2024!
SOLVED

Custom Javascript code to send non-pageview image request s.tl() sending as pageview

Avatar

Level 4

I have a use case where I cannot use the usual method of collecting custom event data via Adobe Data Collection which is creating a rule then setting action as Adobe Analytics - Set Variables, then Send Beacon then Clear Variables. I need to tightly control what data is sent with the hit to Adobe. In Data Collection the rule fires. My main issue is with the Action in the rule, which is set to Custom Code. To control the data I want to send to AA, I'm using Javascript to set a few variables then send the data via s.tl() method. The issue is that when the call is sent it's sent as a page view. In the Experience Platform Debugger, isPageView is true on the hit. It should be false; it should be a s.tl() with the link type being "o" (custom link). This is the code. What needs to be changed to make it a non-pageview hit? Btw all the vars I'm setting and sending are fine and being collected, the only issue is the hit being a page view.

 

<script src="AppMeasurement.js"></script>
<script>
// Instantiate the Analytics tracking object with report suite ID
var s_account = "myreportsuiteid";
var s=s_gi(s_account);
// Make sure data is sent to the correct location
s.trackingServer = "my.trackingserver.com";

 

//Assign all vars we need to collect
s.pageName = page_name;
s.eVar1 = location.pathname.split("/").slice(-1)[0];
s.eVar2 = document.location.href;
s.events = "event32";

// Send hit to Adobe
s.tl();

</script>

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Your s.tl() syntax is wrong. You haven't specified any of the required parameters. E.g. in your post, you mentioned that you had set the "o" value, but then in your example code, you just use "s.tl()". See the documentation at https://experienceleague.adobe.com/docs/analytics/implementation/vars/functions/tl-method.html?lang=...

// wrong
s.tl();

// correct
s.tl(this, "o", "link name");

Furthermore, assuming that in your Adobe Analytics extension, you have selected the "Make tracker globally accessible" checkbox (in the Library Management section), then you should be able to call "s" directly in your custom code without needing to use s_gi(s_account), i.e.

// you can do this straightaway without needing to use s_gi()
// if you have made the tracker globally accessible
s.pageName = page_name;
s.eVar1 = location.pathname.split("/").slice(-1)[0];
s.eVar2 = document.location.href;
s.events = "event32";

Try the above and see if it works properly for you.

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Your s.tl() syntax is wrong. You haven't specified any of the required parameters. E.g. in your post, you mentioned that you had set the "o" value, but then in your example code, you just use "s.tl()". See the documentation at https://experienceleague.adobe.com/docs/analytics/implementation/vars/functions/tl-method.html?lang=...

// wrong
s.tl();

// correct
s.tl(this, "o", "link name");

Furthermore, assuming that in your Adobe Analytics extension, you have selected the "Make tracker globally accessible" checkbox (in the Library Management section), then you should be able to call "s" directly in your custom code without needing to use s_gi(s_account), i.e.

// you can do this straightaway without needing to use s_gi()
// if you have made the tracker globally accessible
s.pageName = page_name;
s.eVar1 = location.pathname.split("/").slice(-1)[0];
s.eVar2 = document.location.href;
s.events = "event32";

Try the above and see if it works properly for you.

Avatar

Level 4

I made some changes and it works now. @yuhuisg , I added parameters to the s.tl() as suggested. Looks like this.

 

s.pageName = _satellite.getVar("Page Name");
s.eVar1 = _satellite.getVar("Page Name");
s.eVar2 = _satellite.getVar("Page URL");
s.events = "event32";

s.linkTrackVars="events,eVar1,eVar2";
s.linkTrackEvents="event32";

s.tl(this,"o","mylink");