{"id":21,"date":"2018-02-01T01:20:09","date_gmt":"2018-02-01T01:20:09","guid":{"rendered":"http:\/\/www.bestworldsweb.com\/blog\/?p=21"},"modified":"2019-05-10T19:20:43","modified_gmt":"2019-05-10T19:20:43","slug":"removing_pii_from_google_adwords_and_remarketing","status":"publish","type":"post","link":"https:\/\/bestworlds.com\/blog\/removing_pii_from_google_adwords_and_remarketing\/","title":{"rendered":"Removing PII from Google Adwords and Remarketing using Google Tag Manager"},"content":{"rendered":"<p>Sending PII (personally identifiable information) to Google Analytics, Adwords or Remarketing can get your Google account suspended. A common scenario is for an email address to be passed in the query string by a CRM or Email Service Provider. But what if you need that to happen for business reasons, so it\u2019s not an option to suppress the inclusion of that data getting passed in to your website?<br \/>\n<!--more--><\/p>\n<p>Ironically it\u2019s Google\u2019s own javascript code for Analytics, Adwords and Remarketing that sends this data over, without any easy way to have it suppress query string parameters or filter out certain key pairs. Even our Google Account Managers could offer no solution for how to get our Adwords and Remarketing tags to stop sending over PII to them.<\/p>\n<p>Furthermore it can be hard to detect what you&#8217;re actually sending to Google using their own tools like the Google Tag Assistant, and the preview mode of Google Tag Manager.<\/p>\n<p>When we first faced this challenge and the threat of suspension by Google we tried several things, like this <a href=\"https:\/\/www.simoahava.com\/analytics\/google-tag-manager-history-listener\/\" target=\"_blank\" rel=\"noopener\">approach from Simo Ahava<\/a> to remove PII from Google Analytics. But Google kept telling us our Remarketing and Adwords were still receiving PII, which we eventually determined was because the raw URL was also being sent to those two regardless of what we tried to feed to them as \u201clocation\u201d values and such through Google Tag Manager.<\/p>\n<p>But finally our team member Jose Oronoz, with the help of Simo Ahava\u2019s post on the <a href=\"https:\/\/www.simoahava.com\/analytics\/google-tag-manager-history-listener\/\" target=\"_blank\" rel=\"noopener\">Google Tag Manager History Listener<\/a>, came up with a way to overwrite the URL stored in the browser history before any other calls are made, so there\u2019s no chance of sending any PII to any external services. The approach uses a custom event trigger firing on the gtm.load event and then it searches for and replaces any PII and overwrites the value the browser stores using the history.replaceState method of the HTML DOM.<\/p>\n<p>After implementing this solution our clients were cleared by Google.<\/p>\n<p>Here\u2019s a step by step explanation of how to implement this using Google Tag Manager.<\/p>\n<h2>Create a Custom Event Trigger<\/h2>\n<p>Create a new trigger of type \u201cCustom Event\u201d:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-59 size-medium\" src=\"https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/create-custom-event-trigger-option-800x511.png\" alt=\"Create a custom event trigger - Step 1\" width=\"800\" height=\"511\" srcset=\"https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/create-custom-event-trigger-option-800x511.png 800w, https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/create-custom-event-trigger-option-768x491.png 768w, https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/create-custom-event-trigger-option.png 981w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/p>\n<p>Then in the Trigger configuration set the \u201cEvent Name\u201d to \u201cgtm.load\u201d which will result in this trigger firing every time Google Tag Manager is fired:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-70\" src=\"https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/create-custom-event-trigger-detail-768x373-1.png\" alt=\"\" width=\"768\" height=\"373\" \/><\/p>\n<h2>Create a New Custom HTML Tag:<\/h2>\n<p>Now we\u2019ll create a new Tag of type \u201cCustom HTML\u201d and connect our trigger to it:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-71\" src=\"https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/create-new-custom-html-tag-step-1-800x406.png\" alt=\"\" width=\"800\" height=\"406\" srcset=\"https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/create-new-custom-html-tag-step-1-800x406.png 800w, https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/create-new-custom-html-tag-step-1-768x389.png 768w, https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/create-new-custom-html-tag-step-1.png 998w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/p>\n<p>After creating the tag, enter the following javascript in the \u201cHTML\u201d section:<\/p>\n<p><textarea style=\"border: none; background-color: white; min-height: 670px; background: #f0f0f0;\" disabled=\"disabled\" ><br \/>\n<script>\nfunction urlpath() {\n\/\/Specify which query string keys we\u2019re searching for\nvar params = [\"email\",\"Email\"];\nvar newUrl = document.createElement(\"a\");\nnewUrl.href = {{Page URL}};\nvar searchString = newUrl.search;\nif (searchString == \"\") return;\nvar pushStateFlag = false;\nfor (i = 0; i < params.length; i++) {\ncurrentQ = new RegExp(params[i] + \"=[^&#038;]*&#038;?\", \"g\");\nif (currentQ.test(searchString)) {\nsearchString = searchString.replace(currentQ, \"\");\npushStateFlag = true;\nbreak;\n}\n}\nif (pushStateFlag) {\nsearchString = searchString.replace(\/[?&#038;]$\/, \"\");\n\/\/Overwrite browser history with non-PII URL\nhistory.replaceState({state:1, rand: Math.random()}, '', newUrl.pathname + searchString);\n}\n\nreturn newUrl.pathname + searchString\n}\n\nurlpath();\n<\/script><br \/>\n<\/textarea><\/p>\n<p>It will look like this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-72\" src=\"https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/create-new-custom-html-tag-step-2-800x527.png\" alt=\"\" width=\"800\" height=\"527\" srcset=\"https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/create-new-custom-html-tag-step-2-800x527.png 800w, https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/create-new-custom-html-tag-step-2-768x506.png 768w, https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/create-new-custom-html-tag-step-2.png 967w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/p>\n<p>We set our \u201cTag Firing Priority\u201d to 100 to make sure it got priority to fire before any other tag:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-73\" src=\"https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/create-new-custom-html-tag-step-3-800x575.png\" alt=\"\" width=\"800\" height=\"575\" srcset=\"https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/create-new-custom-html-tag-step-3-800x575.png 800w, https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/create-new-custom-html-tag-step-3-768x552.png 768w, https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/create-new-custom-html-tag-step-3.png 937w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/p>\n<p>Then in the \u201cTriggering\u201d section choose the Trigger you created in the previous step:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-74\" src=\"https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/create-new-custom-html-tag-step-4-800x589.png\" alt=\"\" width=\"800\" height=\"589\" srcset=\"https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/create-new-custom-html-tag-step-4-800x589.png 800w, https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/create-new-custom-html-tag-step-4-768x565.png 768w, https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/create-new-custom-html-tag-step-4.png 967w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/p>\n<h2>Verify PII is Being Removed<\/h2>\n<p>The final step is to test the removal of PII using the Google Tag Assistant - in our case we were removing the key \u201cemail\u201d so we append a simple \u201cemail=test@test.com\u201d to the URL of one of our websites running Google Tag Manager to see what the Google Tag Assistant will pick up:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-75\" src=\"https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/verify-pii-is-being-removed-step-1-800x291.png\" alt=\"\" width=\"800\" height=\"291\" srcset=\"https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/verify-pii-is-being-removed-step-1-800x291.png 800w, https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/verify-pii-is-being-removed-step-1-768x279.png 768w, https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/verify-pii-is-being-removed-step-1-1200x436.png 1200w, https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/verify-pii-is-being-removed-step-1.png 1320w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/p>\n<p>Submitting that request to the website, and with Google Tag Manager in \u201cPreview\u201d mode, we see that our script is triggered in the windows load event, removing the email before any other tags fire:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-76\" src=\"https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/verify-pii-is-being-removed-step-2-800x256.png\" alt=\"\" width=\"800\" height=\"256\" srcset=\"https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/verify-pii-is-being-removed-step-2-800x256.png 800w, https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/verify-pii-is-being-removed-step-2-768x246.png 768w, https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/verify-pii-is-being-removed-step-2.png 1079w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/p>\n<p>Once you confirm that the script is being executed in the windows load event, you can review the values being sent to Google Analytics and Remarketing, using the <a href=\"https:\/\/chrome.google.com\/webstore\/detail\/tag-assistant-by-google\/kejbdjndbnbjgmefkgdddjlbokphdefk\" rel=\"noopener\">Google Tag Asistant extension<\/a>:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-77\" src=\"https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/verify-pii-is-being-removed-step-3.png\" alt=\"\" width=\"448\" height=\"395\" \/><\/p>\n<p>To check the URL being sent to Google Remarketing, click on \u201cRemarketing Tag\u201d, and then click \u201cRequests\u201d:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-78\" src=\"https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/verify-pii-is-being-removed-step-4.png\" alt=\"\" width=\"445\" height=\"599\" \/><\/p>\n<p>Then click on the URL and confirm that the PII you entered on the URL in the browser has been removed:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-79\" src=\"https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/verify-pii-is-being-removed-step-5.png\" alt=\"\" width=\"445\" height=\"606\" \/><\/p>\n<h2>Wait For Your Policy Breach Resolved Email<\/h2>\n<p>Then hopefully a few days later you will receive a Policy Breach Resolved notice from Google, and you can breathe easier:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-80\" src=\"https:\/\/bestworlds.com\/blog\/wp-content\/uploads\/2018\/02\/wait-for-your-policy-breach-resolved-email.png\" alt=\"\" width=\"610\" height=\"289\" \/><\/p>\n<h2>Conclusion<\/h2>\n<p>Some businesses have good reasons for passing personally identifiable information between various systems, and there are reasons that data can\u2019t be passed via POST or easily encoded at origin. If you find yourself in this situation with Google please add your voice to ours in asking them to think about why they would suspend paying merchants for data that Google\u2019s own scripts are sending. Instead of hacking the DOM history to get this done, Google\u2019s scripts should be updated to only pass data that can be controlled within Google Tag Manager or by configuration changes to the tags themselves.<\/p>\n<p>Please drop us a line if this helped you!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sending PII (personally identifiable information) to Google Analytics, Adwords or Remarketing can get your Google account suspended. A common scenario is for an email address to be passed in the query string by a CRM or Email Service Provider. But what if you need that to happen for business reasons, so it\u2019s not an option &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/bestworlds.com\/blog\/removing_pii_from_google_adwords_and_remarketing\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Removing PII from Google Adwords and Remarketing using Google Tag Manager&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":55,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"content-type":"","rank_math_lock_modified_date":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-21","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-marketing-advertising"],"_links":{"self":[{"href":"https:\/\/bestworlds.com\/blog\/wp-json\/wp\/v2\/posts\/21"}],"collection":[{"href":"https:\/\/bestworlds.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bestworlds.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bestworlds.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bestworlds.com\/blog\/wp-json\/wp\/v2\/comments?post=21"}],"version-history":[{"count":22,"href":"https:\/\/bestworlds.com\/blog\/wp-json\/wp\/v2\/posts\/21\/revisions"}],"predecessor-version":[{"id":82,"href":"https:\/\/bestworlds.com\/blog\/wp-json\/wp\/v2\/posts\/21\/revisions\/82"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/bestworlds.com\/blog\/wp-json\/wp\/v2\/media\/55"}],"wp:attachment":[{"href":"https:\/\/bestworlds.com\/blog\/wp-json\/wp\/v2\/media?parent=21"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bestworlds.com\/blog\/wp-json\/wp\/v2\/categories?post=21"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bestworlds.com\/blog\/wp-json\/wp\/v2\/tags?post=21"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}