GA Event Tracking Code for Affiliate Links

If you have affiliate links on your website, you may want to consider a click on those links as a goal completion. Because a click on those links would result in the visitor leaving your site, you’ll need to set up event tracking on any affiliate links you wish to track as goals. Use the form to build GA Event tracking code for an Affiliate Link. Then add the code to the affiliate link to track the event.


Universal Event Tracking Code Builder for an Affiliate Link

(The name you supply for the group of objects you want to track. We recommend using something like “affiliate link”):

(Used to define the type of affiliate link. We recommend using something like “Netflix”):

(Optional. We recommend using something to further describe the affiliate link (e.g. “Free Trial”).):

(Optional. If you’d like to assign a numeric value to your affiliate link, enter that value here):

(Optional. Select “true” if you want to consider it a bounce when a visitor views one page, submits a contact form and leaves without viewing any other pages.)


Place the following code within the code of your affiliate link:

It should look something like this for your affiliate link:


Optional Goal Setup

After you add the affiliate link event tracking code to your link(s), you may want to setup a goal in Google Analytics that's related to the event. Follow these instructions to setup the goal.

  1. Login to Google Analytics and click on Admin in the main navigation.
  2. Select the Account and Property where you want to create the goal. Under the View list, click on Goals
  3. Click on the New Goal button, click on the Custom radio button and then click on the Next step button.
  4. Name the goal and select the Event radio button.
  5. Populate all of the relevant goal details (in bold):
    • Category | that matches |
    • Action | that matches |
    • Label | that matches |
    • Value | that matches |
  6. Click the Create Goal button. You're done!