Setting up and tracking custom dimensions and metrics in Google Tag Manager (GTM) is a powerful way to gain deeper insights into user behavior on your website or app. Custom dimensions and metrics allow you to collect additional data beyond the standard Google Analytics (GA) reports. Below is a step-by-step guide on how to set up and track custom dimensions and metrics using GTM.
Step 1: Define Your Custom Dimensions and Metrics
Before you start configuring GTM, it’s essential to define what custom dimensions and metrics you want to track. Custom dimensions are attributes of your users or sessions, while custom metrics are numerical values you want to measure.
Examples:
- Custom Dimensions: User type (e.g., member vs. guest), content category, user ID.
- Custom Metrics: Number of purchases, time spent on a specific section of your site.
Step 2: Set Up Custom Dimensions and Metrics in Google Analytics
- Log in to Google Analytics:
- Go to your GA property.
- Navigate to Admin:
- In the bottom left corner, click on the Admin gear icon.
- Select Property:
- Under the Property column, click on Custom Definitions.
- Create Custom Dimensions:
- Click on Custom Dimensions.
- Click the + New Custom Dimension button.
- Enter the name, select the scope (User, Session, Hit, or Product), and mark it as active.
- Click Save.
- Create Custom Metrics:
- Click on Custom Metrics.
- Click the + New Custom Metric button.
- Enter the name, select the scope (hit-level), and define the formatting type (e.g., Integer, Currency).
- Click Save.
Step 3: Set Up GTM Variables for Custom Dimensions and Metrics
- Log in to Google Tag Manager:
- Go to your GTM account.
- Create Variables:
- Click on Variables from the left sidebar.
- Click on New to create a new variable.
- Name your variable (e.g., “User Type”).
- Choose the variable type based on what data you want to track (e.g., Data Layer Variable, JavaScript Variable).
- For Data Layer Variable:
- Enter the Data Layer variable name (e.g.,
userType
).
- Enter the Data Layer variable name (e.g.,
- For JavaScript Variable:
- Enter the JavaScript variable path (e.g.,
window.userType
).
- Enter the JavaScript variable path (e.g.,
- Save the variable.
- Repeat this process for all custom dimensions and metrics you want to track.
Step 4: Create a Google Analytics Tag to Send Custom Dimensions and Metrics
- Create a New Tag:
- Click on Tags from the left sidebar.
- Click New to create a new tag.
- Name your tag (e.g., “GA – Custom Dimensions”).
- Choose Tag Type:
- Click on Tag Configuration and select Google Analytics: Universal Analytics (or GA4 if you’re using Google Analytics 4).
- Track Type:
- Choose Page View for standard tracking or select another type based on your tracking needs.
- Set Up Custom Dimensions:
- Scroll down to More Settings and click to expand it.
- Click on Custom Dimensions.
- Click Add Custom Dimension.
- In the Index field, enter the index number assigned to the custom dimension in Google Analytics (e.g., 1, 2, etc.).
- In the Dimension Value field, select the variable you created earlier (e.g.,
{{User Type}}
). - Repeat for all custom dimensions.
- Set Up Custom Metrics:
- Still under More Settings, click on Custom Metrics.
- Click Add Custom Metric.
- Enter the index number assigned to the custom metric in Google Analytics.
- In the Metric Value field, select the corresponding variable (e.g.,
{{Purchase Count}}
). - Repeat for all custom metrics.
Step 5: Set Up Triggers
- Add Trigger:
- Click on Triggering to add a trigger for when this tag should fire.
- Choose an existing trigger (like All Pages) or create a new trigger that suits your needs (e.g., for specific events).
Step 6: Publish Your Changes
- Preview Your Changes:
- Click on the Preview button in GTM to test your configuration. This allows you to verify that your tag fires correctly and that the custom dimensions and metrics are sent to Google Analytics.
- Check Google Analytics:
- Open your Google Analytics account and navigate to Real-Time reports to see if the data is coming through correctly.
- Publish:
- Once you’ve confirmed everything is working correctly, click on the Submit button in GTM to publish your changes.
Step 7: Validate Data in Google Analytics
After implementation, it’s essential to verify that your custom dimensions and metrics are tracking correctly in Google Analytics.
- Check Reports:
- Go to the relevant reports in Google Analytics (e.g., Audience, Behavior) to see your custom dimensions and metrics.
- For custom dimensions, navigate to Custom Reports or use Secondary Dimensions in standard reports.
- Debugging:
- If data isn’t showing as expected, revisit GTM to ensure variables and triggers are set up correctly, and use the GTM Preview mode to debug.
Conclusion
Setting up and tracking custom dimensions and metrics in Google Tag Manager provides valuable insights that can enhance your understanding of user behavior. By following these steps, you can successfully configure GTM to send this data to Google Analytics, enabling you to make informed decisions based on your unique metrics. Regularly review and adjust your tracking strategy to ensure it aligns with your business goals and provides the insights you need for growth.