Skip to main content

2.6.9 How to capture and parse the LeadJourney CLICKID When Using Copecart

Jonas Strambach avatar
Written by Jonas Strambach
Updated over 3 weeks ago

If you're using Copecart's external checkout pages, and you want to track conversions accurately with LeadJourney, you’ll need to pass the CLICKID from your website to Copecart.

This ensures that LeadJourney can later match conversions sent via webhook back to the original ad click—giving you full attribution.


🧠 Why This Is Necessary

Copecart opens in a separate external page, which breaks the session and removes access to localStorage/cookies.


To avoid losing the tracking data, we need to:

  1. Grab the CLICKID from localStorage or cookie

  2. Append it to all Copecart links as a URL parameter (lj_click_id=...)

  3. Let Copecart store it so that you can send it later in a webhook to LeadJourney


✅ Implementation: Copy & Paste Script

Add the following script at the end of the <body> tag on your site:


<script>
(function() {
function getClickId() {
const lsId = localStorage.getItem('clickid');
if (lsId) return lsId;

const match = document.cookie.match(/(?:^|;\s*)clickId=([^;]*)/);
return match ? decodeURIComponent(match[1]) : null;
}

function addClickIdToUrl(url, clickId) {
const separator = url.includes('?') ? '&' : '?';
return url + separator + 'lj_click_id=' + encodeURIComponent(clickId);
}

document.addEventListener('DOMContentLoaded', function() {
const clickId = getClickId();
if (!clickId) return;

document.querySelectorAll('a[href*="copecart.com"]').forEach(link => {
link.addEventListener('click', function() {
if (!link.href.includes('lj_click_id=')) {
link.href = addClickIdToUrl(link.href, clickId);
}
});
});
});
})();
</script>

🔍 What This Script Does

  • Looks for the LeadJourney CLICKID in both localStorage and cookies

  • Finds all links pointing to copecart.com

  • Automatically adds lj_click_id=... to the URL when the user clicks the link


📦 Example:

If your original Copecart link is:

https://www.copecart.com/products/xyz

It becomes:

https://www.copecart.com/products/xyz?lj_click_id=abc123xyz

Now Copecart will store that parameter and you can include it in your webhook to LeadJourney later as the CLICKID.


🧩 Next Step: Send Offline Conversions

When someone purchases via Copecart, send a webhook to LeadJourney including:

  • lj_click_id (retrieved from Copecart)

  • Your custom conversion event (e.g. "WonClient" etc.)

This allows us to attribute the sale back to the original click and ad campaign.


💬 Need help setting this up or customizing for your stack?


Just reach out via live chat in the bottom-right corner—we’ll support you!

Did this answer your question?