How to track outbound links and file downloads with Google Tag Manager

Author:

Tracking outbound links and file downloads with Google Tag Manager allows you to monitor when users click on links that lead them away from your site (outbound links) or download files hosted on your site. Here’s a detailed guide on how to set up tracking for outbound links and file downloads using Google Tag Manager:

1. Log in to Google Tag Manager

  1. Navigate to Google Tag Manager and select your GTM account and container.

2. Create Variables (if necessary)

Before setting up tags and triggers, ensure you have the necessary variables set up in Google Tag Manager to capture outbound link clicks and file downloads:

a. Click Variables (for Outbound Links)

  1. Click on “Variables” in the left sidebar of your GTM dashboard.
  2. Click on “New” to create a new variable.
  3. Choose “Variable Configuration” and select “Click URL”.
  4. Name your variable (e.g., “Click URL”) and click on “Save”.

b. File Extension Variables (for File Downloads)

  1. Click on “Variables” in the left sidebar of your GTM dashboard.
  2. Click on “New” to create a new variable.
  3. Choose “Variable Configuration” and select “Page Path”.
  4. Name your variable (e.g., “Page Path”) and click on “Save”.

3. Set Up Tags

a. Tag for Outbound Link Tracking

  1. Create a New Tag:
    • Click on “Tags” in the left sidebar of your GTM dashboard.
    • Click on “New” to create a new tag.
  2. Tag Configuration:
    • Choose a tag type. For outbound link tracking, select “Google Analytics: Universal Analytics” if you are using Universal Analytics (gtag.js).
    • Set the following fields:
      • Tag Configuration: Choose “Event” as the track type.
      • Category: Enter a category name (e.g., “Outbound Link”).
      • Action: Specify an action name (e.g., “Click”).
      • Label (Optional): Add additional details if needed (e.g., destination URL).
  3. Trigger Configuration:
    • Click on “Triggering” to set up a new trigger.
    • Choose “Trigger Configuration” and select “Just Links”.
    • Configure the trigger to fire on clicks that match conditions:
      • Click URL contains “http://” or “https://” (to capture all outbound links).
    • Name your trigger (e.g., “Outbound Link Click Trigger”) and click on “Save”.

b. Tag for File Download Tracking

  1. Create a New Tag:
    • Click on “Tags” in the left sidebar of your GTM dashboard.
    • Click on “New” to create a new tag.
  2. Tag Configuration:
    • Choose a tag type. For file download tracking, select “Google Analytics: Universal Analytics” if you are using Universal Analytics (gtag.js).
    • Set the following fields:
      • Tag Configuration: Choose “Event” as the track type.
      • Category: Enter a category name (e.g., “File Download”).
      • Action: Specify an action name (e.g., “Download”).
      • Label (Optional): Add additional details if needed (e.g., file name or extension).
  3. Trigger Configuration:
    • Click on “Triggering” to set up a new trigger.
    • Choose “Trigger Configuration” and select “Click – Just Links”.
    • Configure the trigger to fire on clicks that match conditions:
      • Page Path contains “.pdf”, “.doc”, “.xls”, etc. (for each file extension you want to track).
    • Name your trigger (e.g., “File Download Trigger”) and click on “Save”.

4. Preview and Test

  1. Enter Preview Mode:
    • Click on “Preview” to enter preview mode in GTM.
  2. Test Outbound Links and File Downloads:
    • Open your website in a new tab and click on outbound links or download files to test if the tags fire correctly.
    • Use the GTM preview mode to verify that events are being tracked as expected.

5. Publish Changes

  1. Publish Your Tags and Triggers:
    • Once you’ve verified that the outbound link and file download tracking is working as expected, click on “Submit” in GTM to publish your changes live.

6. View Events in Google Analytics

  1. Access Google Analytics:
    • Log in to your Google Analytics account and select the property and view where you set up the outbound link and file download tracking.
  2. Navigate to Events:
    • Go to “Behavior” > “Events” > “Top Events” to see an overview of the events tracked.
  3. Analyze Event Data:
    • Drill down into specific event categories, actions, and labels to analyze outbound link clicks and file download events.
    • Use secondary dimensions to gain additional insights (e.g., source/medium, landing page).

Additional Tips

  • Regular Monitoring: Monitor event data regularly to identify trends and optimize your website’s content and user experience.
  • Enhanced E-commerce Tracking: For file downloads that lead to purchases or conversions, consider implementing enhanced e-commerce tracking in Google Analytics for more detailed insights.
  • Data Layer (Advanced): For more dynamic tracking or specific conditions, use a data layer in GTM to capture additional information about outbound links or file downloads.

By following these steps, you can effectively set up outbound link and file download tracking using Google Tag Manager, enabling you to gain valuable insights into user interactions and optimize your website’s performance accordingly.