Setting Up a Google Analytics Account for User Consent

Franklyn Edekobi
2 min readAug 15, 2024

--

Google Analytics is a robust tool for tracking and analyzing user interactions on your website. To effectively implement user consent management with Google Analytics, follow these steps to set up your account:

1. Create a Google Analytics Account

  • Visit the Google Analytics website and sign in with your Google account.
  • Click on the Admin gear icon at the bottom left of the page.
  • Under the Account column, click on Create Account and provide a name for your account.
  • Under the Property column, click on Create Property to set up a new property. Provide a name, select your time zone and currency, and click Next.
  • Choose your data stream type (Web, Android app, or iOS app) and set up your data stream by entering your website URL or app details.

2. Obtain the Google Tag (gtag.js)

  • After creating your property, you’ll be given a Measurement ID and instructions on how to implement the global site tag (gtag.js).
  • Copy the gtag.js code snippet provided in the setup instructions.
  • Paste the code into the <head> section of your website's HTML. This ensures that Google Analytics is loaded on every page of your site.

For a React application, go to public > index.html

Example:

<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || []
function gtag() {
dataLayer.push(arguments)
}
gtag('js', new Date())
gtag('config', 'G-XXXXXXXXXX')
</script>

3. Enable Data Collection Settings

  • Go back to your Google Analytics dashboard and navigate to Admin > Property Settings.
  • Ensure that data collection for advertising features is enabled. This will allow you to track data like demographics and interests, which are essential for user consent.

4. Set Up User Consent Preferences

  • Within the Google Analytics Admin section, go to Data Settings > Data Collection.
  • Here, you can configure consent settings, allowing users to opt in or opt out of data collection. This is crucial for complying with GDPR and other data protection regulations.

5. Test Your Implementation

  • Once everything is set up, test your implementation by navigating to your website and checking if data is being collected.
  • Use the Real-Time reports in Google Analytics to see if your visits are being tracked.

For more detailed steps and visual aids, refer to this tutorial on setting up a Google Analytics account to get your gtag and begin managing user consent effectively.

This guide should help you set up Google Analytics for your website, allowing you to track user interactions while respecting user consent preferences.

--

--

Franklyn Edekobi

Passionate about creating positive change and making a meaningful contribution towards improving lives. https://www.linkedin.com/in/frank-aiywa-kobi/