I tried using the tool `` Google Tag Manager & Google Analytics Proxy '' for collecting data of users blocking tracking by proxying scripts with Google Analytics



As privacy awareness grows, some users block Google Tag Manager and Google Analytics. As a site operator, I want accurate figures as much as possible, but I don't want to introduce an original analysis tool just for that. The tool ' Google Tag Manager & Google Analytics Proxy ' that penetrates the block and collects data to Google Analytics is useful there.

GitHub - blaumedia/go-gtm-ga-proxy: Bypass any tracking-blocking browser plugins with this first-party-tracking-proxy for Google Tag Manager and Google Analytics.

https://github.com/blaumedia/go-gtm-ga-proxy

The browser's tracking blocking function is implemented to check the communication partner and block it if it is a Google domain. Therefore, the strategy of this application is to set up a proxy server in the same domain as the site and make it unclear whether it is access to Google or access necessary for viewing the site.

A detailed diagram is below. First, rewrite access to Tag Manager to a proxy within the same domain. The proxy then forwards the request to Google's servers instead, rewrites the Google-related domain portion of the returned script to your address, and sends it back to the browser.



The same is true when Tag Manager requests an analytics script.



Data sent to Analytics is also addressed to a proxy server within the same domain, so it is not easy to determine what kind of access it is from the browser side. Also, by giving the IP address of the original client when sending data from the proxy server, it is possible to collect data in the same way as when not proxying.



I actually tried to see if it really works. First, for verification, prepare a web page that contains only the tag manager code.



When you access this page, you can see that the access is done in the order of 'Tag Manager' → 'Analytics'. Of course, the access destination is 'googletagmanager.com' and 'google-analytics.com'.



Since Google Tag Manager & Google Analytics Proxy starts using Docker, install Docker from the link below according to your environment.

Install Docker Engine | Docker Documentation

https://docs.docker.com/engine/install/

Since I am using CentOS this time, I entered the following command.

[code] sudo yum install -y yum-utils
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl start docker[/code]



After Docker can be started, enter the command on the Github page to start the proxy server. Rewrite ENDPOINT_URI to the address for accessing the proxy server, GTM_IDS to the ID of the tag manager, and COOKIE_DOMAIN to the domain name of the site.



Also, you need to provide access to the proxy in your server settings. This time, I rewrote the Apache configuration file to access the proxy server when accessing the '/goproxy' path.



Rewrite the tag manager address to 'domain/goproxy/js/gtm.js~' and remove the leading 'GTM-' part from the last tag manager ID.



Now when I try to access it, the tag manager script has successfully proxied. However, Analytics still accesses Google's servers.



Google Tag Manager & Google Analytics Proxy was last updated in 2021, and it may be because the tag manager script has changed in the two years before the article was created, 'Replace Google Domains in the Script' in the figure below. part does not seem to work well.

in Review,   Software, Posted by log1d_ts