Google Tag Manager (GTM) and Google Analytics (GA) are widely used for monitoring user behavior and performance on websites. They allow us to create tracking tags and triggers without coding to follow how users interact with a site. This provides actionable data to optimize web design and functions.
Together, these tools enable website owners and marketers to gain valuable insights into user website activity. The analytics and tracking capabilities inform data-driven decisions to improve visitor experience.
Google Tag Manager (GTM)
Google Tag Manager (GTM) is a tag management system that helps to easily update tracking code fragments (known as tags) on websites and apps. It works by creating tags, triggers, and variables that help gather data and analytics on web user activity.
Learn how to use Google Tag Manager and create tags and triggers here.
Google Analytics (GA-4)
Google Analytics (GA) is an analytics service used to measure traffic and engagement on websites and apps. We can generate reports on tracked web activity using dimensions and metrics. While real-time and debug views show current data, report generation can take 24-48 hours to process.
Note: Google has announced that starting from July 2023, GA-UA (Universal Analytics) will be replaced by GA-4, and standard Universal Analytics properties will stop processing new data.
Differences between GA-UA and GA-4
Integrating GTM in Drupal
- Install the GTM module.
- Enable the module and click on the Configure button.
3. Click on the containers tab to add a new container.
4. Label the container and add a container ID. You can find the container ID in GTM.
5. Find a container ID starting with GTM-XXXXX, copy the ID, paste it into the container ID input field in Drupal (step 4), and click Save to integrate the tag manager with your Drupal site.
Integrating GA4 in Drupal
- Install and enable the GA module.
- Go to the GA configuration page on Drupal by typing admin/config/services/google-analytics to add a property ID.
- To get the property ID, go to the GA account and search for measurement ID. Copy and paste it in the Web Property field and save the configuration.
4. Connect Tag Manager with Google Analytics. Find out how to do it here.
Integrating GA reports module in Drupal
After integrating GTM with GA to enable tracking and report generation, we can display the data directly on the Drupal site using the Google Analytics Reports module.
- Install the module and enable it.
- Create a new project in Google Developers Console to access the data from Google Analytics.
- Go to Google Cloud and click on the Enabled API’s and services tab.
4. Enable Google Analytics Data API.
5. Go to credentials and create a Service account. Fill up all the details, like service account name, account ID, etc. Skip the optional fields and click on Save.
6. Click on the created service account, find a KEYS tab on the top, and click on it. Then click on ADD KEY → Create a new key → JSON type and → Create to download a JSON file.
7. Go to the Google Analytics reports module config page on Drupal - admin/config/services/google-analytics-reports-api, and upload the downloaded JSON file, and add a property ID. Search for the Property ID in Google Analytics and paste it into the GA reports config. Save the configurations.
8. Go to the configurations page of GA reports and click on the import field to import the fields from Google Analytics. The GA reports module is now configured in the Drupal site.
9. To display the GA data, create a new view page, select Google Analytics in views settings, and click on the Save and Edit button. Add dimensions and metrics in field sections and save the view.
Google Tag Manager and Google Analytics offer robust website tracking and analytics. With seamless integration in Drupal and easy configuration, businesses can access meaningful data analytics and insights to optimize experiences, operations, and performance.