Book the exclusive demo launch to experience the OWOX BI analytics

To finish setting up a user behavior data pipeline from your website to Google BigQuery, you need to integrate an OWOX BI tracking code on your website.

If you're using Google Tag Manager to send website event data to Google Analytics, we recommend you using the customTask method to implement the tracking.

A customTask is a Universal Analytics library feature that lets you set custom behavior for how hits are being sent from the website. This means you can define how and where the data should be sent.

Important:You can't use more than one customTask in one GTM tag. The function of each new customTask overrides the function of the previous one.
If it's crucial for you to use several customTask functions in a single tag, you can join their JavaScript code within a single customTask.

How to set up tracking with customTask

Step 1. In a Google Tag Manager container, create a Custom JavaScript-type customTask variable. In this variable, add one of the two following JavaScript code snippets.

Case 1: Send user behavior data from your website to both Google BigQuery (via an OWOX BI pipeline) and Google Analytics (via your GA tracking code). To do this, add to the created customTask the code that sends data to both Google Analytics and Google BigQuery: 

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)})}}
}

Case 2: Send data to Google BigQuery only and block the Google Analytics tracking. This can be useful if you want not to exceed Google Analytics limits or if your website generates more hits than GA can receive and you don't need to collect incomplete data there. If this is your case, in the customTask use the code for sending data to Google BigQuery only:

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)})}}
}

Step 2. In each of the Universal Analytics tags you use to send data to BigQuery, add your customTask variable to the Fields to Set section. In the Field Name column, make sure you have customTask field without quotes or any other symbols:

customTask_variable_en.png

Step 3. Save the tag and publish the container.

Done! Your pipeline is fully set up and will now be collecting data.

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 special values to Google BigQuery only

If you need to collect to Google BigQuery the data that Google Analytics's tracking code can't process (for example, personal data like phone numbers or emails), you can create a separate Google Tag Manager tag and use a customTask to collect these specific values only directly to Google BigQuery.

To do this:

  1. In a Google Tag Manager container, create a Custom JavaScript-type customTask variable. In this variable, add the code for sending data to Google BigQuery only:
    
     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)})}}
    }
  2. Create one or more Custom JavaScript variables with the code specifically written for collecting these data from the website.
    Note: The JavaScript code in these variables depends solely on the data you want to get from the website, so writing this code must be done from your side.
  3. Create a separate tag that will track the values of these variables:
    customTask_code_GBQ_only_value_en.png
  4. Add to the tag you've created a Custom Dimension for each of the custom variables you want to track and set values for these dimensions in the Dimension Value:customTask_code_GBQ_only_custom_dimension_en.png
  5. Save the tag and publish the container.

Done! Now, this tag will be sending the special values to your Google BigQuery.

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.