@zaplier/sdk 1.7.6 → 1.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +67 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.js +67 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/sdk.js +67 -1
- package/dist/sdk.js.map +1 -1
- package/dist/sdk.min.js +1 -1
- package/dist/src/sdk.d.ts +4 -0
- package/dist/src/sdk.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -21685,6 +21685,70 @@ class ZaplierSDK {
|
|
|
21685
21685
|
window.location.hostname.startsWith("10.") ||
|
|
21686
21686
|
window.location.hostname.includes("local"));
|
|
21687
21687
|
}
|
|
21688
|
+
/**
|
|
21689
|
+
* Extract UTM parameters from current URL
|
|
21690
|
+
*/
|
|
21691
|
+
extractUTMParameters() {
|
|
21692
|
+
const utmParams = {};
|
|
21693
|
+
if (typeof window === "undefined" || !window.location) {
|
|
21694
|
+
return utmParams;
|
|
21695
|
+
}
|
|
21696
|
+
try {
|
|
21697
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
21698
|
+
// Extract UTM parameters (camelCase for consistency with backend)
|
|
21699
|
+
const utmSource = urlParams.get('utm_source');
|
|
21700
|
+
const utmMedium = urlParams.get('utm_medium');
|
|
21701
|
+
const utmCampaign = urlParams.get('utm_campaign');
|
|
21702
|
+
const utmContent = urlParams.get('utm_content');
|
|
21703
|
+
const utmTerm = urlParams.get('utm_term');
|
|
21704
|
+
// Extract click IDs
|
|
21705
|
+
const fbclid = urlParams.get('fbclid');
|
|
21706
|
+
const gclid = urlParams.get('gclid');
|
|
21707
|
+
const ttclid = urlParams.get('ttclid');
|
|
21708
|
+
// Extract ad platform parameters
|
|
21709
|
+
const creativeId = urlParams.get('creative_id');
|
|
21710
|
+
const adId = urlParams.get('ad_id');
|
|
21711
|
+
const adsetId = urlParams.get('adset_id');
|
|
21712
|
+
const campaignId = urlParams.get('campaign_id');
|
|
21713
|
+
const platform = urlParams.get('platform');
|
|
21714
|
+
// Add to result object (only non-null values)
|
|
21715
|
+
if (utmSource)
|
|
21716
|
+
utmParams.utmSource = utmSource;
|
|
21717
|
+
if (utmMedium)
|
|
21718
|
+
utmParams.utmMedium = utmMedium;
|
|
21719
|
+
if (utmCampaign)
|
|
21720
|
+
utmParams.utmCampaign = utmCampaign;
|
|
21721
|
+
if (utmContent)
|
|
21722
|
+
utmParams.utmContent = utmContent;
|
|
21723
|
+
if (utmTerm)
|
|
21724
|
+
utmParams.utmTerm = utmTerm;
|
|
21725
|
+
if (fbclid)
|
|
21726
|
+
utmParams.fbclid = fbclid;
|
|
21727
|
+
if (gclid)
|
|
21728
|
+
utmParams.gclid = gclid;
|
|
21729
|
+
if (ttclid)
|
|
21730
|
+
utmParams.ttclid = ttclid;
|
|
21731
|
+
if (creativeId)
|
|
21732
|
+
utmParams.creativeId = creativeId;
|
|
21733
|
+
if (adId)
|
|
21734
|
+
utmParams.adId = adId;
|
|
21735
|
+
if (adsetId)
|
|
21736
|
+
utmParams.adsetId = adsetId;
|
|
21737
|
+
if (campaignId)
|
|
21738
|
+
utmParams.campaignId = campaignId;
|
|
21739
|
+
if (platform)
|
|
21740
|
+
utmParams.platform = platform;
|
|
21741
|
+
if (this.config.debug && Object.keys(utmParams).length > 0) {
|
|
21742
|
+
console.log("[Zaplier] UTM parameters extracted from URL:", utmParams);
|
|
21743
|
+
}
|
|
21744
|
+
}
|
|
21745
|
+
catch (error) {
|
|
21746
|
+
if (this.config.debug) {
|
|
21747
|
+
console.warn("[Zaplier] Failed to extract UTM parameters:", error);
|
|
21748
|
+
}
|
|
21749
|
+
}
|
|
21750
|
+
return utmParams;
|
|
21751
|
+
}
|
|
21688
21752
|
/**
|
|
21689
21753
|
* Send event to backend
|
|
21690
21754
|
*/
|
|
@@ -21726,7 +21790,9 @@ class ZaplierSDK {
|
|
|
21726
21790
|
}
|
|
21727
21791
|
: undefined,
|
|
21728
21792
|
fingerprintComponents: this.fingerprint?.components || {},
|
|
21729
|
-
|
|
21793
|
+
// CRITICAL: Auto-extract UTM parameters from URL, but allow eventData to override
|
|
21794
|
+
...this.extractUTMParameters(), // Auto-extracted UTM parameters (background)
|
|
21795
|
+
...eventData, // User-provided event data (can override UTM parameters)
|
|
21730
21796
|
timestamp: new Date().toISOString(),
|
|
21731
21797
|
url: typeof window !== "undefined" && window.location
|
|
21732
21798
|
? window.location.href
|