Key Events Commonly Tracked with Google Analytics
There are several types of user interactions that are commonly monitored using Google Analytics:
- Page Views – Counts each time a user visits a page.
- File Downloads – Tracks clicks on downloadable resources like PDFs or ZIP files.
- External Link Clicks – Logs when a user clicks on a link that navigates away from your domain.
- Button Clicks – Monitors interactions with CTAs and other key buttons.
- Form Submissions – Tracks when users successfully submit forms.
- Video Engagement – Measures how users interact with embedded video content.
- Scroll Depth – Analyzes how far down a page users scroll.
- E-commerce Activity – Tracks shopping behavior, from product views to completed transactions.
- Custom Events – Allows you to define and track interactions specific to your website goals.
Source: [GA4] Automatically collected events
Setting Up Google Analytics with Drupal (Example: Tracking Page Views and File Downloads)
1. Create a Data Stream in GA Start by logging into your Google Analytics account and navigating to the Admin section. Under the Data Streams tab, click Add Stream and select Web. Enter your website URL and name your stream clearly. Once created, GA will generate a unique Measurement ID.
Source: [GA4] Set up Analytics for a website and/or app
2. Enable Selective Enhanced Measurement Inside the Data Stream settings, you’ll find the Enhanced Measurement options. Click the gear icon and toggle off unnecessary events, leaving only:
• Page views (default enabled)
• File downloads
3. Manually Embed GA Code into Drupal Instead of using a contributed module, you can directly insert the GA tracking script into your Drupal theme. Locate your theme’s html.html.twig file and add the script inside the tag. This gives you full control over how and when the script is executed. window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
Things to Keep in Mind
- User Consent Comes First - Ensure no tracking scripts are triggered before receiving user permission. Integrating a cookie consent tool is strongly advised.
- Automatic Tracking Still Shares Data - Features like outbound clicks, scrolls, and file downloads might send user data — even without explicit user interaction. These too require consent in most jurisdictions.
- File Downloads and Privacy - Downloads may involve personal data collection (e.g., IP addresses). Treat them as sensitive and request user approval.
- Manual Script = Manual Responsibility - If you’re bypassing modules in favor of custom integration, it’s your job to ensure the script adheres to local data privacy laws and consent rules.
Source: Introduction to user consent management
The Payoff
Properly integrating GA into your Drupal site helps you track key metrics and optimize user experience. With reliable data at your fingertips, you can fine-tune content, improve engagement, and boost your website’s effectiveness — all while staying privacy-compliant.