How to Set up and Track Custom Dimensions and Metrics in Google Tag Manager

Author:

Setting up and tracking custom dimensions and metrics in Google Tag Manager (GTM) allows you to collect specific data points that are not automatically tracked by default in Google Analytics. Custom dimensions are used to collect additional information about hits (such as pageviews, events, or users), while custom metrics are used to quantify and measure user interactions. Here’s a step-by-step guide on how to set up and track custom dimensions and metrics in GTM:

 1. Define Custom Dimensions and Metrics in Google Analytics

  1. Log in to Google Analytics:
  2. Navigate to Admin Settings:
    • In the Admin section, select the property for which you want to create custom dimensions or metrics.
  3. Create Custom Definitions:
    • Under the Property column, click on “Custom Definitions” > “Custom Dimensions” or “Custom Metrics”.
  4. Add New Custom Dimension or Metric:
    • Click on the “+ New Custom Dimension” or “+ New Custom Metric” button.
    • Define the name and scope for the custom dimension or metric.
    • Save your changes.

 2. Set Up Custom Dimensions and Metrics in Google Tag Manager

  1. Access Google Tag Manager:
  2. Navigate to Variables:
    • In your GTM workspace, go to “Variables” on the left-hand side.
  3. Create a New User-Defined Variable:
    • Click on “New” to create a new variable.
    • Choose the appropriate variable type based on whether you’re setting up a custom dimension or metric:
      • Custom JavaScript Variable: Use this for dynamic values or data from your website.
      • Data Layer Variable: Use this if the data is available in your website’s data layer.
      • Lookup Table Variable: Use this if you want to map specific values to your custom dimensions or metrics.
  4. Configure the Variable:
    • Depending on the variable type chosen, configure the settings to capture the desired data.
    • If using Custom JavaScript, write the JavaScript code to extract the necessary data.

 3. Set Up Tags to Send Custom Data to Google Analytics

  1. Create a New Tag:
    • Go to “Tags” in your GTM workspace and click on “New”.
    • Choose the appropriate tag type, typically “Google Analytics: Universal Analytics” for sending data to Google Analytics.
  2. Configure Tag Settings:
    • Set the “Track Type” to the appropriate type (e.g., Page View, Event).
    • Configure the other tag settings as needed, including the Google Analytics Tracking ID.
  3. Add Custom Dimensions/Metrics:
    • In the “More Settings” section of the tag configuration, expand “Custom Dimensions” or “Custom Metrics”.
    • Add the index number of the custom dimension or metric you created in Google Analytics.
    • Select the appropriate variable you created in GTM to populate the value for the custom dimension or metric.
  4. Attach Triggers:
    • Specify when the tag should fire by adding triggers. This could be on specific pageviews, events, or other interactions.

 4. Test Your Setup

  1. Enter Preview Mode:
    • Click on “Preview” in GTM to enter preview mode.
  2. Test Your Tags:
    • Navigate to your website and interact with elements that trigger your tags.
    • Verify in the GTM preview mode that your tags are firing correctly and sending custom data to Google Analytics.

 5. Publish Your Container

Once you’ve tested your setup and verified that your tags are working correctly, you can publish your GTM container to make the changes live:

  1. Submit and Publish:
    • Click on “Submit” in GTM and follow the prompts to publish your container.

 6. Analyze Custom Data in Google Analytics

  1. View Custom Reports:
    • In Google Analytics, navigate to the “Customization” section to create custom reports that include your custom dimensions and metrics.
  2. Analyze Data:
    • Use the custom reports to analyze the data collected through your custom dimensions and metrics.
    • Gain insights into user behavior, segmentation, and other key metrics based on the custom data you’re tracking.

Setting up and tracking custom dimensions and metrics in Google Tag Manager allows you to collect and analyze specific data points that are relevant to your business goals and objectives. By following these steps, you can effectively capture custom data and send it to Google Analytics for analysis and reporting. Regularly monitor and analyze the custom data to gain insights into user behavior, optimize your website, and make data-driven decisions to improve performance.