Book the exclusive demo launch to experience the OWOX BI analytics

OWOX BI tracking code integration with Google Tag Manager

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

If you're using Google Tag Manager to send website event data to Google Analytics, you can also use it to integrate the OWOX BI tracking code.

How to set up website data collection to Google BigQuery tracking with Google Tag Manager

Step 1

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.

Go to the Variables tab, then in the User-Defined Variables section, click New:Custom_task_en_1.png

2. In the window opened, click on the Variable Configuration block and select Custom JavaScript as the variable type:Custom_task_en_2.png

3. Name the variable a customTask; in the Custom JavaScript window, paste the OWOX BI tracking code:Custom_task_en_3.png

You can find the code on your user behavior data pipeline or just copy it from below:

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/"+encodeURIComponent(tracker.get("trackingId"));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)})}}
}

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.
Remember, that modifying the OWOX BI tracking code can lead to data collection issues.

4. Click Save to add the code to the customTask variable. 

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.

1. To do this, go to a Universal Google Analytics tag and click Tag Configuration:Custom_task_en_4.png

2. Select More settings > Fields to set > + Add Field. As Field name, enter customTask. As Value, use {{customTask}}:Custom_task_en_5.png

3. Click Save.

Important:To collect full data on all the website events, add the customTask field to all your Universal Analytics tags. For example, goals, transaction tracking tags etc.

Step 3

Save the tag and publish the container.

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

Check if the integrated code works correctly 

To make sure the code is integrated properly and works correctly, open your user behavior data pipeline page in OWOX BI and go to the Google BigQuery dataset to which the pipeline collects hit data:Custom_task_en_6.png

If the code is integrated correctly, a "streaming_" table will appear in the dataset. The table should receive first hit data within 2 through 5 minutes after you've updated your Google Tag Manager container.

24 hours after the code integration, you can go to the Hits tab on the pipeline's page. If everything works fine, you'll see a Data collected status for the previous day:Custom_task_en_7.png

On the day after first hit data was collected, in the Sessions tab you'll see info on the collected session data. The session data will also appear in your Google BigQuery dataset in a separate table.

Note:
If you see any discrepancies between Google Analytics and OWOX BI/Google BigQuery data after setting up and starting the data collection, please check out this article on the possible reasons for data discrepancy. 

Other data collection use cases

Send data to Google BigQuery only and block 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, instead of the integration code from the pipeline page, 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/"+encodeURIComponent(tracker.get("trackingId"));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)})}}
}

Collect 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. Read this article to learn more.

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.