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.
In ClickFunnels, navigate to your funnel's Settings.
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_IDwith your Tenant ID.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.
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.
Navigate back to your funnel's Settings.
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:
TENANT_ID: your Tenant ID (in all three places)REVENUE_ORIGIN_ID: your Revenue Origin ID
Locate the Footer Code section and paste the script there.
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:
Open your funnel through an affiliate's tracking link. See Testing an Offer for how to get one.
On the page where users enter their email address, enter a test email and click outside the field.
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
leadconversion.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.




