# 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](https://apps.shopify.com/influencer-hero?utm_source=api_docs) 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 `` section or at the bottom of your webpage: ```html ``` 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: ```url 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. ```javascript 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. ```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. ```javascript 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](https://docs.influencer-hero.com/ih_api/affiliate-tracking) API docs. ## 7. Example Integration ```html Influencer Campaign Visit Store ``` ## 8. Next Steps - [Shopify store? Install the Shopify App.](https://apps.shopify.com/influencer-hero?utm_source=api_docs) - [Advanced tracking? See server-side docs.](https://docs.influencer-hero.com/ih_api/affiliate-tracking) - Questions? [Contact Support](mailto:support@influencer-hero.com). That's it! You're ready to track influencer clicks and sales with Influencer Hero.