Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/boynet/cf-GoogleAnalytics-shield-worker
simple cloudflare worker to protect google analytics from being blocked by ad blockers
https://github.com/boynet/cf-GoogleAnalytics-shield-worker
Last synced: 28 days ago
JSON representation
simple cloudflare worker to protect google analytics from being blocked by ad blockers
- Host: GitHub
- URL: https://github.com/boynet/cf-GoogleAnalytics-shield-worker
- Owner: boynet
- Created: 2019-06-11T07:50:22.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-03-04T12:38:27.000Z (almost 5 years ago)
- Last Synced: 2024-08-03T03:04:05.542Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 32
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Google Analytics shield - Cloudflare worker
simple cloudflare worker to protect google analytics from being blocked by ad blockers(it can be anywhere around 5 to 30 percent of the users)It works by proxy the google analytics script file and endpoint url.
right now it support only the `analytics.js` tracking and the `https://www.google-analytics.com/*collect` endpoint
there is other urls which not proxied right now(which will get blocked), in my case I dont need them, like:
* ampcid.google.com
* stats.g.doubleclick.net## How to install:
* change UrlPrefix and EndPointScramble Parameters to random string, a common ads\analytics related words will get blocked
* make your worker route to url matches `http://example.com/UrlPrefix*`
* change your site google analytics script from `https://www.google-analytics.com/analytics.js` to `/UrlPrefix.js`
* (change UrlPrefix to the value you used in the worker parameter)## Warnings:
* pay attention to the gdpr law
* if you have millions of requests I am not 100% sure its good idea to use it as google can rate limit the cloudflare worker ips, as the ips are shared between all cloudflare accounts so its good idea to reconsider it\ask google about it
* make sure to rescramble the urls from time to time### todo:
- [ ] log failed requests
- [ ] proxy all the urls needed for analytics(?)
- [ ] support the new gtag.js script
- [ ] auto scrambled the endpoint from time to time