Google Analytics 4 - Affiliate Link Clicks Tracking

How do I track affiliate link clicks in Google Analytics 4?

03.02.2023 — 

A step-by-step guide

The tracking of external links (outbound links) is integrated in Google Analytics 4. The corresponding event is called"click" - this is triggered for all outbound links. If you only want to see the actual affiliate links in a report, you need to set up a special event with the corresponding parameters. This is possible both directly in the GA4 property and via the Google Tag Manager. The second option is more flexible and can be used if many unique affiliate domains are in use. If one or two domains are involved, it is sufficient to set this up directly in the configuration of the GA4 property.

Goal: Track affiliate link clicks and display them in the GA4 report

In this article, we look at examples of (fictitious) affiliate links from amazon.de and otto.de - the aim of the report is to see how often these links are clicked on by website visitors, which URL it is exactly and on which of our subpages the clicks occur.

Preparatory measures

First of all, check whether the "Outbound clicks" option is activated for the web stream in the Optimized analyses section. The option is activated when the GA4 property is first set up. If this is not the case, you can simply activate it!

The way to the setting: Administration > Data streams > "Your stream name" > Events [Optimized analyses] > Click on gear > "Click on external links".

Option 1 - User-defined event in the GA4 property

This method is well suited if only a few different affiliate partners are linked on the website. If there are many different affiliate domains, tracking should be controlled via the Google Tag Manager, see option 2.

  • Configure > Events > "Create event" > "Create"
  • Specify event name - e.g. "affiliate_link_click"
  • Matching conditions:
    • event_name IS EQUAL click
    • link_url INCLUDES amazon.com
  • Option 1 - User-defined event in the GA4 property
      1. Testing: You can test whether the event is triggered as desired in the DebugView of GA4 (Configure > DebugView) - In addition, the Chrome Extension Google Analytics Debugger must be installed and activated so that the correct debug signals are sent to the DebugView.
      2. The event "affiliate_link_click" should now appear in the DebugView when clicking on the affiliate link. By clicking on the event, you will find the passed parameter "link_url", which contains the affiliate URL as a value. If this is the case, everything is set up correctly and you can access this event via your reports after approx. 24 hours in order to evaluate it.
      3. To track the second affiliate link otto.de, simply repeat steps 1-5. The event name should be exactly the same. Only "amazon.de" should be replaced by "otto.de" in the matching conditions.

      Tip: You can copy existing events. To do this, open one of the events and click on COPY in the three-dot menu at the top right.

      How to use the event in the evaluation is explained below.

      Use of the event in the evaluation
        Option 2 - Implement GA4-Afilliate Link Tracking via Google Tagmanager
          1. Create a new tag with the name (e.g.) "GA4 event - affiliate_link_click"
            • Select "GA4 event" as the tag type
            • Select the correct cofiguration tag in the dropdown
            • Specify "affiliate_link_click" as the event name
            • Add event parameter > line
              • Parameter name: link_url
              • Value: {{Click URL}}
              • Assign trigger: "Affiliate Link Click" (as created above)
              • Save
          1. Test! Use the preview mode of the tag manager. Is the tag "GA4 event - affiliate_link_click" fired when clicking on the affiliate links? Does the new event "affiliate_link_click" appear in the GA4 DebugView and does it have the correct URL as a parameter? Then everything is set up correctly and the new features in the tag manager can be published.
          Testing in the preview mode of the tag manager
            Witalli Reingard

            We take over!

            GTM, Google Analytics 4, events, parameters, DebugView - it's easy to lose track. As an SEO agency and Google Premium Partner, we are happy to support you with the setup, configuration and tracking extension as well as the creation of corresponding reports in GA4 or Google Looker Studio.