Try out all OWOX BI features with a trial period Start for free

OWOX BI tracking code integration with analytics.js on-site code (DEPRECATED METHOD)

Important!Today, Google Analytics offers to install only a new type of counter on the site – Global Site Tag (gtag.js). There is no way to embed the OWOX BI tracking code in it, due to the limitation of the ability to run third-party scripts.
Therefore, we recommend that you implement the OWOX BI tracking code via Google Tag Manager following this instruction.

If you are using legacy analytics.js counter on your site, then in this article you will find out all the methods to include OWOX BI tracking code into your website.

Two options of how to collect data from your website

Option 1: Send data to both Google BigQuery and Google Analytics.

OWOX BI tracking code will be sending user behavior data to Google BigQuery and Google Analytics tracking code will keep sending them to Google Analytics.

To use this option, add these snippets to the code on each page of your website that contains a Google Analytics tracking code:

1. After the Google Analytics initialization command (ga('create', 'UA-... ); line) add:

// Connecting OWOX BI Streaming plugin to the tracker
ga('require', 'OWOXBIStreaming');

 2. After the line ga('send', 'pageview');, add:

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

 

Option 2: 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, then add these snippets to the code on each page of your website that contains a Google Analytics tracking code:

1. After the Google Analytics initialization command (ga('create', 'UA-... ); line) add:

// Connecting OWOX BI Streaming plugin to the tracker
ga('require', 'OWOXBIStreaming');

 2. After the line ga('send', 'pageview');, add:

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

 

Important: If you use several Google Analytics trackers on one page, then, in the code provided above, specify the name of the tracker you want to use OWOX BI Pipeline.

For example, if the tracker's name is 'owox' — add ga('owox.require', 'OWOXBIStreaming'); instead of ga('require', 'OWOXBIStreaming');.

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

0 Comments

Please sign in to leave a comment.