UTM Parameters Not Getting Captured for Tracking URL

UTM Parameters Not Getting Captured for Tracking URL

Problem Statement

UTM parameters are not getting captured for the tracking URL.

The CX is using their own website with a custom form instead of a LeadSquared landing page form.

Root Cause Analysis (RCA)

  • The tracking script is installed correctly.

  • Prospects are being generated successfully.

  • The issue occurs during lead capture because the Prospect ID is not being passed in the payload.

When using a custom form (V2 API), the JavaScript global variable MXCProspectId must be picked from the browser and passed along with the API payload.

Additionally:

  • For existing leads, the API response returns the original Prospect ID.

  • This returned Prospect ID must be updated in the browser to ensure proper tracking continuity.

If this step is missed, UTM attribution will not work correctly.

Solution

The following JavaScript function must be added to the CX’s website to properly set and update the Prospect ID:

function setProspectParameters(leadId, orgCode, trackingDomain) {

let expiryDate = new Date();

expiryDate.setTime(expiryDate.getTime() + (365 * 24 * 60 * 60 * 1000));

document.cookie = 'ORG' + orgCode + '=' + leadId + ';expires=' + expiryDate.toUTCString() + ';Domain=' + trackingDomain + ';path=/;';

MXCProspectId = leadId;

window.leadsquared.tracker.pids[orgCode] = leadId;

}

// Sample function call
// Replace 77318 with the org code and clientdomain.com with the website domain where it is used
setProspectParameters(leadId, 77318, 'clientdomain.com');

Important

  • This implementation is required only when the CX is using a custom form with the V2 API.

  • If the CX is using a LeadSquared landing page form, this step is not required, as Prospect ID handling is managed automatically.

Expected Outcome

Once the Prospect ID is correctly passed and updated in the browser:

  • UTM parameters will be captured accurately.

  • Lead attribution will function as expected.

  • Tracking continuity will be maintained for both new and existing leads.

    • Related Articles

    • Capturing UTM parameters using Portal Widget

      ** Optimizing Lead Tracking with Portal Widgets ** Optimize your lead tracking process effortlessly with the seamless integration of Portal Widgets. Empowering Lead Tracking through Portal Widgets is now a reality. Here’s how: ** Understanding API ...
    • Understanding UTM Parameter Behavior for Repeat Landing Page Submissions

      Overview: This article explains how LeadSquared handles UTM parameters when a lead submits a landing page form multiple times, and why UTM values may not update on subsequent submissions. What are UTM Parameters? UTM parameters are values passed ...
    • Unable to Capture Source and Sub-Source Using Tracking URL

      Issue: Unable to Capture Source and Sub-Source Using Tracking URL. RCA: Cx was using IFrame and on IFrame domain and website domain is different. Solution: We asked customer to create website domain's subdomain for landing page and republish the ...
    • Managing URL Expiration for Portal Access

      This article addresses the scenarios related to the expiration of short and long URLs used for accessing the portal. Understanding these scenarios can help users troubleshoot issues and maintain access. Scenarios 1. Expired Short URL Issue: When a ...
    • Custom Menu not Getting Rendered

      Scenario: The user configured a custom menu in the mobile application. However, when attempting to open it on mobile, the page fails to render and displays the error: “URL Not Secure.” Root Cause: When attempting to access the endpoint within the ...