On 20-21 August, meet Affise in India: Click Summit!
How to Integrate Affise Web SDK with Google Tag Manager (GTM): A Complete Guide How to Integrate Affise Web SDK with Google Tag Manager (GTM): A Complete Guide

  • Blog
  • Events
  • How to Integrate Affise Web SDK with Google Tag Manager (GTM): A Complete Guide

How to Integrate Affise Web SDK with Google Tag Manager (GTM): A Complete Guide

Are you looking for a flexible way to track your affiliate marketing campaigns without constantly editing your website’s code? Integrating the Affise Web SDK with Google Tag Manager (GTM) is the perfect solution. GTM allows you to deploy and manage your tracking scripts with ease, giving you the power to track clicks and conversions accurately and efficiently.

This step-by-step guide will show you exactly how to configure end-to-end Affise tracking in GTM, from the initial click to the final conversion.

Prerequisites

Before you begin, make sure you have the following:

  • An active Affise account with white label domain (recommended).
  • A Google Tag Manager container installed on your website with a trigger configured for your desired conversion event(s).

Step 1: Set Up Affise Click Tracking for Landing Pages

The first step is to capture the initial touchpoint when a user arrives from an affiliate link. This tag should only fire once on the user’s landing page to ensure data accuracy.

  1. Create a New Custom HTML Tag: In your GTM account, navigate to Tags > New. Name your tag something clear, like Affise - Click Tracking. For the tag type, select Custom HTML.

Affise Click Tracking
  1. Paste the Click Tracking Script: Add the following script to the HTML field. This code captures the offer_idand aff_id from the URL, generates a click

    <script src="<https://csdemo.g2afse.com/websdk.js>"></script>

    <script>

    var offerId = ASDK.urlParameter('offer_id') || 'DEFAULT_OFFER'; var affiliateId = ASDK.urlParameter('aff_id') || 'DEFAULT_AFFILIATE';

    ASDK.click({ offer_id: offerId, affiliate_id: affiliateId, user_agent: navigator.userAgent }) .then(function(clickId) { console.log('Tracking initialized:', clickId); }) .catch(function(error) { console.error('Tracking error:', error.message); }); </script>

Click Tracking Script

3. Add a “All Pages – Page View” Trigger: This will generate the click when the user visits the page. If the click is already generated, then it won’t be created on the subsequent visits of the page.

Page View Trigger

Step 2: Implement Affise Conversion Tracking in GTM

Next, you need to track when a user completes a key action, like a purchase or a form submission. This conversion tag will link the action back to the original click.

  1. Create a New Conversion Tag: Go to Tags > New, name it Affise - Conversion Tracking, and select the Custom HTML tag type.

New Conversion Tag
  1. Add the Conversion Tracking Script: Paste the code below. This script is smart; it retrieves the offer_id saved in the previous step and uses it to find the correct clickId automatically stored by the SDK.

    <script src="<https://csdemo.g2afse.com/websdk.js>"></script>

    <script>

    var offerId = ASDK.urlParameter('offer_id'); var clickId = ASDK.clickId(offerId);

    ASDK.conversion({ click_id: clickId, offer_id: offerId, status: '1' // 1 = confirmed })

    .then(function() { console.log('Conversion tracked successfully'); })

    .catch(function(error) { console.error('Error tracking conversion:', error); });

    </script>

3. Choose Your Conversion Trigger: Click Triggering and select the event that defines a conversion. This will be unique to your website. Common examples include:

Conversion Trigger
  • Page View trigger for a “Thank You” or “Order Confirmation” page (e.g., Page URL contains /thank-you).
  • Custom Event trigger that fires when a specific action, like a purchase, is pushed to the data layer.

Pro Tip: Ensure Accurate Tracking in Safari and Other Browsers

To ensure your tracking works reliably across all browsers, especially those with privacy features like Safari’s Intelligent Tracking Prevention (ITP), your tracking links must contain the necessary parameters. The click tracking script relies on this data being present in the URL when the user first lands on your site.

Make sure your tracking links are formatted correctly: https://yourwebsite.com/?offer_id={offer_id}&aff_id={pid}

Accurate Tracking in Safari

By following this guide, you have successfully set up a powerful and robust Affise tracking system using Google Tag Manager, enabling you to make data-driven decisions to grow your affiliate program.

Share this article
Dmitry Hodosok

Written by

Dmitry is a product manager with an interest in technology and affiliate marketing. He is passionate about improving products through a customer-centric, data-driven approach. In his free time, he enjoys traveling and reading.

Sign up to receive our newsletter

Stay on top of the competition. Let us keep you updated with news, insights, and more

email envelope