track affiliate link with gtm

Tracking the affiliated link with GA4 and GTM is useful because we can set up conversion on the link as it will show you how many conversions have been done by a user who has clicked on your website link and goes to your partner’s website to buy things.

The main goal of the affiliated link is to make people click the link on our website

To set up this tracking, firstly you need to set a few things

–        Get an affiliate link on your website or shop page

–        The affiliated link needs to be connected to your partner’s website.

–        GA4 needs to be installed on your website

–        Tag manager needs to be installed on your website

Do not use both Google Analytics 4 and Google Tag Manager at the same time for affiliated links clicked

Either use the tag manager or use analytics

If you have a simple affiliated link then use Affiliated linked tracking in GA4

now in the Google Tag Manager, you need to set up your Base GA4 tag

and you need to go to the Variable section

  • make sure all the Click variables in the build-in variable is enabled

Creating Trigger

now go to Triggers and create a new link click triggers

  • Click on New
  • Click on Trigger configuration
  • Select Just Link trigger

now we will use the regular expression where we can use the ‘|’ expression for ‘OR’

in our example, we can say
amazon.com|example.com converts to amazon.com OR example.com

Now save the trigger.

Creating Tag

Now we need to create a Tag for this event

  • go to the Tag section
  • click on Tag Configuration
  • select Google Analytics: GA4 Event
  • choose the GA4 base code in the tag configuration Base GA4 tag
  • Give the name of the event
    affiliated_link_click
  • now give the event parameters
    parameter name: link_url
    value: {{Click URL}} (choose from the variable section)

now choose the Trigger that we created above
Save

Now you can test your tag by going to the Preview mode or going to Debug mode on your GA4

Do not forget to Publish your workspace and save all your tags and trigger

Recent Posts