Grab free access to all the OWOX BI features for 14 days

To finish setting up a user behavior data pipeline from your website to Google BigQuery, you need to integrate a tracking code on your website. This article describes how to do it using the customTask method.

A 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 site users behavior with OWOX BI.

The customTask is being overwritten each time the hit is sent to OWOX BI.

In rare cases when you need several customTasks for one tag, unite their code under a single customTask.

How to setup tracking with customTask

  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){
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)})}}
}
  1. Add the customTask variable to the Fields to Set block in each Universal Analytics tag for which you want to send the data to Google BigQuery:

__________109.png

Please note:
If you see any discrepancies in Google Analytics after setting up and starting the data collection, please read about the possible discrepancy reasons in this article. 

Sending data to OWOX BI only

In the tags where you need to send data to OWOX BI only, skipping Google Analytics, create a customTask variable using the following code:


 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){h.send(d.get("hitPayload"));tracker.set("OWOXBIStreaming",!0)})}}
}

By setting different customTask variables for different tags, you can regulate the data sources for each event's tag.

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

0 Comments

Please sign in to leave a comment.