Skip to main content

ClickFunnels Email Attribution

Use ClickFunnels lead emails for conversion attribution.

This guide explains how to integrate ClickFunnels with Trackdesk to support email attribution for leads. This setup is particularly useful if you want to connect email forms to external tools like Stripe for attribution.

This setup needs a funnel in ClickFunnels. Check that you have one, and if not, create it first.


​

Step-by-step instructions

Step 1: Create a funnel in ClickFunnels

Navigate to your ClickFunnels dashboard and ensure the funnel you wish to track is active and ready for configuration.

​

Step 2: Install the click tracking code

To track clicks, you must include the following tracking script on every page of your funnel.

  1. In ClickFunnels, navigate to your funnel's Settings.

  2. Copy the following Click Tracking code:

    <!-- Trackdesk tracker begin -->
    <script async src="//TENANT_ID.trackdesk.com/main.js"></script>
    <script>
    (function(t,d,k){(t[k]=t[k]||[]).push(d);t[d]=t[d]||t[k].f||function(){(t[d].q=t[d].q||[]).push(arguments)}})(window,"trackdesk","TrackdeskObject");

    trackdesk("TENANT_ID", "click");
    </script>
    <!-- Trackdesk tracker end -->

    Replace both occurrences of TENANT_ID with your Tenant ID.

  3. Locate the Head Code section in your ClickFunnels settings and paste the code at the top of it, so the click is recorded before the visitor can leave the page.

  4. Click Update Funnel to save your changes.

Step 3: Install the lead and email script

Next, you need a specific script to capture the user's email address and send it to Trackdesk as a lead. This script should be placed on the page where users enter their email address.

  1. Navigate back to your funnel's Settings.

  2. Copy the following Lead and Email script code:

    <!-- Trackdesk process email and send lead for internal flow - START -->
    <script async src="//TENANT_ID.trackdesk.com/main.js"></script>
    <script>
    (function(t,d,k){(t[k]=t[k]||[]).push(d);t[d]=t[d]||t[k].f||function(){(t[d].q=t[d].q||[]).push(arguments)}})(window,"trackdesk","TrackdeskObject");

    document.addEventListener("DOMContentLoaded", function() {
    let emailInput = document.querySelector("input[name='email']");

    if (emailInput) {
    emailInput.addEventListener("blur", function() { // Fires when user leaves the field
    let emailValue = emailInput.value.trim();

    // Email validation: must contain @, a domain, and a dot (e.g., [email protected])
    let emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;

    if (emailPattern.test(emailValue)) {
    // Send lead conversion
    trackdesk("TENANT_ID", "conversion", {
    "conversionType": "lead"
    });

    // Send the email as External CID
    trackdesk("TENANT_ID", "externalCid", {
    "externalCid": emailValue, // Using email as externalCid
    "revenueOriginId": "REVENUE_ORIGIN_ID"
    });
    }
    });
    }
    });
    </script>
    <!-- Trackdesk process email and send lead for internal flow - END -->

    Replace these values:

  3. Locate the Footer Code section and paste the script there.

  4. Click Update Funnel to finish the setup.

Once completed, your setup is ready to support email attribution, whether you are using Stripe customer email attribution or other email-based methods.


​

Testing your integration

Before launching your affiliate program, we highly recommend running a test to verify everything is set up correctly:

  1. Open your funnel through an affiliate's tracking link. See Testing an Offer for how to get one.

  2. On the page where users enter their email address, enter a test email and click outside the field.

  3. In Trackdesk, open the Click report and look at the External CID column. The test email should appear there, and the Conversion report should show a new lead conversion.

  4. Complete a test purchase with the same email address and check that the sale appears in the Conversion report.

If the email is missing from the Click report, the script from Step 3 is not firing on the page where users enter their email address.

Did this answer your question?