Set up special values collecting 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=""+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)&&("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:
  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?
2 out of 2 found this helpful
Have more questions? Submit a request


Please sign in to leave a comment.