Skip to main content

ClickFunnels Email Attribution

Use ClickFunnels lead emails for conversion attribution.

Written by Trackdesk Team

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.

Before starting, ensure you have already created a funnel within your ClickFunnels account.


​

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 there.

  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.

Did this answer your question?