Skip to main content

ClickFunnels Email Attribution

Written by Sasha Gerold
Updated over 2 weeks ago

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="//cdn.trackdesk.com/tracking.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("YOUR_TENANT_ID", "click");
    </script>
    <!-- Trackdesk tracker end -->


    ⚠️ Make sure to replace YOUR_TENANT_ID with your actual Trackdesk 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="//cdn.trackdesk.com/tracking.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)) {
    // 🔥 FIRE TRACKDESK CODE 1 (Conversion Tracking)
    trackdesk("YOUR_TENANT_ID", "conversion", {
    "conversionType": "lead"
    });

    // 🔥 FIRE TRACKDESK CODE 2 (External CID Tracking)
    trackdesk("YOUR_TENANT_ID", "externalCid", {
    "externalCid": emailValue, // Using email as externalCid
    "revenueOriginId": "YOUR_REVENUE_ORIGIN_ID"
    });
    }
    });
    }
    });


    ⚠️ Make sure to replace YOUR_TENANT_ID with your Tenant ID and YOUR_REVENUE_ORIGIN_ID with your Revenue Origin ID.

  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?