{"id":16412489,"url":"https://github.com/coliff/prevent-pii-tracking-in-google-analytics","last_synced_at":"2026-02-02T10:17:20.956Z","repository":{"id":148063688,"uuid":"124502847","full_name":"coliff/prevent-pii-tracking-in-google-analytics","owner":"coliff","description":"Prevent PII being tracked in Google Analytics","archived":false,"fork":false,"pushed_at":"2018-03-09T12:43:02.000Z","size":27,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-24T06:14:51.460Z","etag":null,"topics":["google-analytics","ppi"],"latest_commit_sha":null,"homepage":"https://coliff.github.io/prevent-pii-tracking-in-google-analytics/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coliff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"coliff","ko_fi":"coliff","custom":"https://paypal.me/coliff"}},"created_at":"2018-03-09T07:15:32.000Z","updated_at":"2018-03-09T10:50:03.000Z","dependencies_parsed_at":"2023-03-31T17:02:59.812Z","dependency_job_id":null,"html_url":"https://github.com/coliff/prevent-pii-tracking-in-google-analytics","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/coliff/prevent-pii-tracking-in-google-analytics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coliff%2Fprevent-pii-tracking-in-google-analytics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coliff%2Fprevent-pii-tracking-in-google-analytics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coliff%2Fprevent-pii-tracking-in-google-analytics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coliff%2Fprevent-pii-tracking-in-google-analytics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coliff","download_url":"https://codeload.github.com/coliff/prevent-pii-tracking-in-google-analytics/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coliff%2Fprevent-pii-tracking-in-google-analytics/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259835393,"owners_count":22918980,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["google-analytics","ppi"],"created_at":"2024-10-11T06:49:06.872Z","updated_at":"2026-02-02T10:17:15.935Z","avatar_url":"https://github.com/coliff.png","language":"HTML","funding_links":["https://github.com/sponsors/coliff","https://ko-fi.com/coliff","https://paypal.me/coliff"],"categories":[],"sub_categories":[],"readme":"# Prevent PII from being tracking in Google Analytics\n\nGoogle don't allow PII (Personally Identifiable Information) to be tracked in Google Analytics. You can have your Google Analytics account suspended if you don't abide by the rules.\n\nGoogle provide some helpful [Best Practises information](https://support.google.com/adsense/answer/6156630?hl=en), but their suggestions often rely on rewriting your web application so that PPI aren't displayed in the URL.\n\nThis work-around script works by only including Google Analytics tracking snippet if the URL **does not** include `email`, `username` or `password` strings. The exact strings could easily be modified to suit your needs.\n\n``` html\n\u003cscript\u003e\n  window.ga=function(){ga.q.push(arguments)};ga.q=[];ga.l=+new Date;\n  ga('create','UA-XXXXX-Y','auto');ga('send','pageview')\n\u003c/script\u003e\n\u003cscript\u003e\n  if(location.href.match(/(?:\\b|_)(?:username|email|password)(?:\\b|_)/i) \u003e -1){\n  document.write('\u003cscript src=\"https://www.google-analytics.com/analytics.js\" aysnc defer\u003e\u003c\\/script\u003e');\n  }\n\u003c/script\u003e\n```\n\n## Demo\n\n[https://coliff.github.io/prevent-pii-tracking-in-google-analytics/demo.htm](https://coliff.github.io/prevent-pii-tracking-in-google-analytics/demo.htm) - this page loads Google Analytics as normal\n\nIf you include params with PII (`email`, `username` or `password`) the URL though, Google Analytics will not load:\n\n- [demo.htm?username=redacted%40example.com\u0026password=Z0CS9](https://coliff.github.io/prevent-pii-tracking-in-google-analytics/demo.htm?username=redacted%40example.com\u0026password=Z0CS9)\n\n- [demo.htm?userName=redacted%40example.com\u0026token=9234](https://coliff.github.io/prevent-pii-tracking-in-google-analytics/demo.htm?userName=redacted%40example.com\u0026token=9234)\n\n- [demo.htm?email=redacted%40example.com\u0026token=%3%tX](https://coliff.github.io/prevent-pii-tracking-in-google-analytics/demo.htm?email=redacted%40example.com\u0026token=%3%tX)\n\n\nNote; the optimized Google Analytics snippet is from [HTML5Boilerplate](https://github.com/h5bp/html5-boilerplate/blob/master/src/index.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoliff%2Fprevent-pii-tracking-in-google-analytics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoliff%2Fprevent-pii-tracking-in-google-analytics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoliff%2Fprevent-pii-tracking-in-google-analytics/lists"}