From 5ba35048c523c380b6ed2904a8354c1dd71ec0e1 Mon Sep 17 00:00:00 2001 From: Kostiantyn Horozhanov Date: Fri, 12 Jul 2024 14:53:59 +0200 Subject: [PATCH 1/2] Added common cookie support --- template.js | 10 ++++++---- template.tpl | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/template.js b/template.js index 73e3b63..05149ed 100644 --- a/template.js +++ b/template.js @@ -41,8 +41,10 @@ if (url && url.lastIndexOf('https://gtm-msr.appspot.com/', 0) === 0) { return data.gtmOnSuccess(); } -let fbc = getCookieValues('_fbc')[0]; -let fbp = getCookieValues('_fbp')[0]; +const commonCookie = eventData.common_cookie || {}; + +let fbc = getCookieValues('_fbc')[0] || commonCookie._fbc; +let fbp = getCookieValues('_fbp')[0] || commonCookie._fbp; if (!fbc) fbc = eventData._fbc; if (!fbp) fbp = eventData._fbp; @@ -672,11 +674,11 @@ function setGtmEecCookie(userData) { function enhanceEventData(userData) { const cookieValues = getCookieValues('_gtmeec'); - if (!cookieValues || cookieValues.length === 0) { + if ((!cookieValues || cookieValues.length === 0) && !commonCookie._gtmeec) { return userData; } - const encodedValue = cookieValues[0]; + const encodedValue = cookieValues[0] || commonCookie._gtmeec; if (!encodedValue) { return userData; } diff --git a/template.tpl b/template.tpl index 5136765..f68b3cb 100644 --- a/template.tpl +++ b/template.tpl @@ -775,8 +775,10 @@ if (url && url.lastIndexOf('https://gtm-msr.appspot.com/', 0) === 0) { return data.gtmOnSuccess(); } -let fbc = getCookieValues('_fbc')[0]; -let fbp = getCookieValues('_fbp')[0]; +const commonCookie = eventData.common_cookie || {}; + +let fbc = getCookieValues('_fbc')[0] || commonCookie._fbc; +let fbp = getCookieValues('_fbp')[0] || commonCookie._fbp; if (!fbc) fbc = eventData._fbc; if (!fbp) fbp = eventData._fbp; @@ -1406,11 +1408,11 @@ function setGtmEecCookie(userData) { function enhanceEventData(userData) { const cookieValues = getCookieValues('_gtmeec'); - if (!cookieValues || cookieValues.length === 0) { + if ((!cookieValues || cookieValues.length === 0) && !commonCookie._gtmeec) { return userData; } - const encodedValue = cookieValues[0]; + const encodedValue = cookieValues[0] || commonCookie._gtmeec; if (!encodedValue) { return userData; } From 49c5ef1a3f8af5ac46909c22927e128592135b6b Mon Sep 17 00:00:00 2001 From: Kostiantyn Horozhanov Date: Fri, 12 Jul 2024 15:00:21 +0200 Subject: [PATCH 2/2] Meta update --- metadata.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/metadata.yaml b/metadata.yaml index 8b72f2f..e775e72 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -1,5 +1,7 @@ homepage: 'https://stape.io/' versions: + - sha: 5ba35048c523c380b6ed2904a8354c1dd71ec0e1 + changeNotes: Added common cookie support. - sha: 1ab4ccc09f86a65f2e2256b862f2b47f851b9075 changeNotes: Added support of x-fb-cd-content_type. - sha: e1e5321231eaa46c13b397d5cedaa207ecefa7a8