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:
- 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/"+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)})}}
} - 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. - Create a separate tag that will track the values of these variables:
- 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:
- Save the tag and publish the container.
Done! Now, this tag will be sending the special values to your Google BigQuery.
0 Comments