This article describes the method of using customTask to integrate the OWOX BI Pipeline tracking code into your website. The alternative to this method is to set up tracking with a Custom HTML tag. Both methods are acceptable. However, we recommend using the customTask method described below.

The customTask will be executed each time a hit is sent to Google Analytics. By default, this Task does nothing and can be overwritten for tracking purposes.

To set up tracking with customTask, please do the following:

  1. In Google Tag Manager, create a user-defined JavaScript variable using the code below. The name of the variable should be set to customTask:

__________105.png

 

function() {
return function(tracker){
tracker.set("dimensionXX", tracker.get("clientId")+"_"+Date.now());

if("undefined"===typeof tracker.get("OWOXBIStreaming")){var f=tracker.get("sendHitTask"),h=function(){function d(c){var a=!1;try{document.createElement("img").src=e(!0)+"?"+c,a=!0}catch(k){}return a}function e(c){var a="https://google-analytics.bi.owox.com/collect";c||(a+="?tid="+encodeURIComponent(tracker.get("trackingId")));return a}return{send:function(c){var a;if(!(a=2036>=c.length&&d(c))){a=!1;try{a=navigator.sendBeacon&&navigator.sendBeacon(e(),
c)}catch(g){}}if(!a){a=!1;var b;try{window.XMLHttpRequest&&"withCredentials"in(b=new XMLHttpRequest)&&(b.open("POST",e(),!0),b.setRequestHeader("Content-Type","text/plain"),b.send(c),a=!0)}catch(g){}}return a||d(c)}}}();tracker.set("sendHitTask",function(d){f(d);h.send(d.get("hitPayload"));tracker.set("OWOXBIStreaming",!0)})}}
}

Please note: Replace the XX in the code with the index of the custom dimension used to send the sessionID.

  1. Add the customTask variable to the Field to Set in each Universal Analytics tag for which you want to send the data to Google BigQuery:

__________109.png

 

Using OWOX BI Pipeline to collect hit data only:

If the pipeline is configured to collect hit data only, please use the following code in the customTask variable:

function() {
    return function(tracker){

    if("undefined"===typeof tracker.get("OWOXBIStreaming")){var f=tracker.get("sendHitTask"),h=function(){function d(c){var a=!1;try{document.createElement("img").src=e(!0)+"?"+c,a=!0}catch(k){}return a}function e(c){var a="https://google-analytics.bi.owox.com/collect";c||(a+="?tid="+encodeURIComponent(tracker.get("trackingId")));return a}return{send:function(c){var a;if(!(a=2036>=c.length&&d(c))){a=!1;try{a=navigator.sendBeacon&&navigator.sendBeacon(e(),
c)}catch(g){}}if(!a){a=!1;var b;try{window.XMLHttpRequest&&"withCredentials"in(b=new XMLHttpRequest)&&(b.open("POST",e(),!0),b.setRequestHeader("Content-Type","text/plain"),b.send(c),a=!0)}catch(g){}}return a||d(c)}}}();tracker.set("sendHitTask",function(d){f(d);h.send(d.get("hitPayload"));tracker.set("OWOXBIStreaming",!0)})}}
}

 

Please note:
If you see any discrepancies in Google Analytics after setting up and starting the data collection, please refer to this article.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.