
How to Get a Google Analytics Tracking ID for Your Server
- August 18, 2021
I started with the assumption that Google Analytics would track me.
After some research, I discovered that it doesn’t.
In fact, the most popular analytics tracking methods on Google Analytics aren’t even tracking my website traffic, let alone tracking any of my personal data.
Google Analytics, after all, only has a limited number of tracking tools that work for tracking a site’s traffic and users, and none of them are available on my server.
As a result, the only tracking I needed was my Google Analytics tracking ID, which I could grab from the website’s analytics dashboard.
The problem is, this tracking ID isn’t available to anyone outside of Google Analytics.
Here’s what to do if you need a Google analytics tracking ID: Make sure your server is set up to allow tracking If you’ve got a Google Cloud Platform (GCP) server that has been configured to allow Google Analytics traffic tracking, you can add the tracking ID to the server’s configuration file.
In this example, I’m using the Apache web server and the Apache webserver-specific configuration file, so I’ll just use the configuration file that I’ve found on my Windows Server 2012 R2 machine.
Open up your Apache web browser, and navigate to your server’s /etc/apache2/sites-available/google-analytics.conf file.
If you’re using a virtual machine, you might need to add the server to your firewall’s network.
If the default configuration file doesn’t exist, open it with sudo nano /etc /apache2 /etc.conf.d/apache.conf and add the following line at the top of the file: ServerName my-server <?php echo '’; ?> google-api.mydomain.com 44b7b6e8-3f7b-4b67-ae8c-a3ffa7e4e4dc Now that your server has been set up, you should be able to add it to your Apache logs by typing the following command: grep -v -e ‘/apache-logs/Google/analytics’ -e ”; For example, to check if your server was enabled for Google Analytics logs: grep ‘apache-server-enabled’ -v ” -E ‘Google’ If you don’t see the output, make sure you’re running Apache on a different server.
For more information about the Google Analytics log files, check out this Google Developer blog post.