Last updated

Tracking Script

This page explains how to integrate and use the Influencer Hero client-side tracking script. The script enables you to track affiliate clicks and referrals on your website, attributing them to the corresponding influencer deal.

Note: If you're using Shopify, we recommend our official Shopify App Integration instead.


1. Overview

What is the Influencer Hero Tracking Script?

Influencer Hero’s tracking script allows you to:

  • Automatically track affiliate clicks via the provided Influencer Hero UTM links
  • Track referrals or leads.
  • Manually track clicks (This is only needed if you are not using the Influencer Hero native UTM links).

Tracked data is sent to Influencer Hero and reflected in the influencer’s deal page.


2. Installing the Script

Include the following script tag in the <head> section or at the bottom of your webpage:

<script src="https://files.influencer-hero.com/clicks.js" defer></script>

The script will automatically track visits that are using the native Influencer Hero links. You can find those links on the influencers deal page.

If you’re just here to set up automatic click tracking, you’re all set!


3. Automatic Click Tracking

An influencer shares a link:

https://yourwebsite.com/?utm_source=influencer&utm_campaign=myinfluencer+12345
  • You can find the influencer's UTM link on the influencer deal page of our dashboard.
  • Clicks are tracked automatically if the Influencer Hero link is used.
  • Nothing more to do from your side if you only want to track clicks and are using our native IH links.

4. Sale Tracking

Manually attribute a referral to an influencer.

InfluencerHero.registerSale({
  order_id: '1234',                   // Optional
  order_revenue: '45.67',             // Optional
  currency: 'USD',                    // Optional
  order_platform: 'us-store',         // Optional
  discount_codes: 'CODE1,CODE2',      // Optional
  order_name: 'Order #1234',          // Optional
  order_notes: 'High-value customer'  // Optional
});

Parameters

  • order_id: Unique order ID. If you send the same order_id multiple times, only the first one will be processed. If you do not specify one, we will generate a UUID.
  • order_revenue: Sale amount.
  • currency: Currency code (USD, EUR).
  • order_platform: Platform identifier if needed.
  • discount_codes: Comma-separated discount codes.
  • order_name: Readable order name.
  • order_notes: Additional notes.

Attributing leads

You can also use this to attribute leads e.g. for a signup form. In that case you would call the InfluencerHero.registerSale function when a new lead is created (e.g. a visitor clicked submit on a lead form). You can either specify order_revenue as 0 or attribute a certain dollar value to a lead.

Example: Attributing a Lead via Button Click

The below example will only work if the website visitor came in through an Influencer Hero UTM link. Otherwise, you will need to specify the collab_id manually.

<!DOCTYPE html>
<html lang="en">
<head>
    <script src="https://files.influencer-hero.com/clicks.js" defer></script>
</head>
<body>
    <button id="leadButton">Register Lead</button>
    <script>
        document.getElementById('leadButton').addEventListener('click', function() {
            InfluencerHero.registerSale({
                order_id: 'lead-' + Date.now(),
                order_revenue: '0',
                currency: 'USD',
                order_notes: 'Lead registered via button click'
            });
            console.log('Lead registered successfully!');
        });
    </script>
</body>
</html>

5. Manual Click Tracking (Advanced)

Manually track clicks without UTM parameters. This is only necessary if you are not using the native Influencer Hero links.

InfluencerHero.registerClick({
  collab_id: 'abc123',           // Optional
  deal_id: 'dealXYZ',            // Optional
});
  • collab_id: Collaboration ID.
  • deal_id: Deal identifier (optional - we need either the collab_id or deal_id).

6. Server-Side Tracking (Advanced)

For robust tracking without client-side scripts, use Influencer Hero’s server-side tracking. Details in the Affiliate Tracking API docs.


7. Example Integration

<!DOCTYPE html>
<html>
<head>
  <title>Influencer Campaign</title>
  <script src="https://files.influencer-hero.com/clicks.js" defer></script>
</head>
<body>

  <!-- Automatic Tracking via UTM -->
  <a href="https://yourwebsite.com/?utm_source=influencer&utm_campaign=myinfluencer+12345">
    Visit Store
  </a>

  <!-- Sale Tracking -->
  <script>
    InfluencerHero.registerSale({
      order_id: 'ORDER-1001',
      order_revenue: '59.99',
      currency: 'USD',
      discount_codes: 'SUMMER20',
      order_notes: 'Via influencer link'
    });
  </script>
</body>
</html>

8. Next Steps


That's it! You're ready to track influencer clicks and sales with Influencer Hero.