SiteCatalyst: Tracking Custom Links in Webkit Browsers

My request is that I have a link that redirects to another page. In webkit browsers, how to get the sitecatalyst server call to complete (script execution) before the redirect occurs?

I am using sitecatalyst for the portal. I have configured a custom link call to enable the doneAction parameter to successfully complete the call in webkit browsers (as indicated in the Adobe manual).

The custom link code for the onClick enable button is as follows:

<script language="javascript" > function search(keyword) { var s=s_gi('testing'); s.linkTrackVars="prop11,events"; s.linkTrackEvents="event6"; s.prop11=keyword; s.events="event6"; s.tl(this,'o','Search',navigate()); window.location=searchresults.html; } </script> <script language="javascript" > function navigate() { return false; /*To induce a delay to ensure that image request is sent to Adobe before the user leaves the page.(As given in Adobe guide - code release H.25)) Code version H.25 (released July 2012) includes an overloaded track link method ( s.tl ) that forces WebKit browsers to wait for the track link call to complete.)*/ } </script> 

However, even after that, I get an error in tracking user links. Redirection occurs before the call ends.

Please help me. Thanks at Advance.

Regards, Harshil

+4
source share
3 answers

So, firstly, there are a number of problems with how you implemented it. Here is an example of how it should look:

 <a href="searchresults.html" onclick="search('someKeyword');return false;">search</a> <script type='text/javascript'> function search(keyword) { var s=s_gi('testing'); s.linkTrackVars="prop11,events"; s.linkTrackEvents="event6"; s.prop11=keyword; s.events="event6"; s.tl(this,'o','Search',null,navigate); return false; } function navigate(){ window.location="searchresults.html"; } </script> 

Some points

  • You have not actually posted a link or anything else that you are using that calls the search function, so I have a link shown as an example.
  • You passed the navigate function as the 4th argument when it should be the fifth (with an empty or empty string as a placeholder for the 4th).
  • This should be navigate not navigate() . As you have done this, you call the function and pass the result of the function as an argument. s.tl requires an actual function or a function reference, and it will call the function. In fairness, the Adobe document is sealed: it shows an example enclosed in quotation marks that does not work.
  • Redirects should be placed in navigate , not search .
+5
source

Replace href link with javascript function

 function trackLink(e) { nextUrl = e.href; e.href = "javascript:sendData('" + nextUrl + "')"; } function sendData(url) { s.tl(this, "o", "Link Name", null, function() { window.location.href = url; }); } 

or try the following steps

 function sendData(obj) { s.tl(obj, "o", "Link Name", null, "navigate"); return false; } 
 <a href="new.html" onclick="sendData(this);return false;">Link</a> 
+1
source

Tracking links is a form of tracking dinosaurs, because these days the numbers are hardly accurate unless you put analytics before starting to work with the user. I don’t understand why you are not measuring this on the next page instead of the link if you do not have control over the next step?

As for your question: the previous examples of how to prevent communication after the event execution are strong enough, but remember, if you have other JS code, be sure not to break it. As for the syntax, you can pass all variables to the s.tl function as an object without setting linkTrackVars and linkTrackEvents for the s-object, which can have negative consequences for events if you use the code on dynamic pages.

eg.

 ... var data = { linkTrackVars="prop11,events", linkTrackEvents="event6", prop11=keyword, events="event6" }; s.tl(this, "o", "Search", data, "navigate"); ... 

Note. In fact, you cannot use details and events in standard reporting. According to the code that you insert in the comments on Crayon, I see that you are using eVars, so I assume that the example was not so accurate.

0
source

Source: https://habr.com/ru/post/1478951/


All Articles