From 3639d997b1a2d25404a82ddaa428e6af05aba1c0 Mon Sep 17 00:00:00 2001 From: Kostiantyn Horozhanov Date: Fri, 12 Jul 2024 15:02:51 +0200 Subject: [PATCH] Added common cookie support --- template.js | 6 ++++-- template.tpl | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/template.js b/template.js index f6bb331..e7a6b74 100644 --- a/template.js +++ b/template.js @@ -31,10 +31,12 @@ if (url && url.lastIndexOf('https://gtm-msr.appspot.com/', 0) === 0) { return data.gtmOnSuccess(); } -let ttclid = getCookieValues('ttclid')[0]; +const commonCookie = eventData.common_cookie || {}; + +let ttclid = getCookieValues('ttclid')[0] || commonCookie.ttclid; if (!ttclid) ttclid = eventData.ttclid; -let ttp = getCookieValues('_ttp')[0]; +let ttp = getCookieValues('_ttp')[0] || commonCookie._ttp; if (!ttp) ttp = eventData._ttp; if (!ttp && data.generateTtp) { ttp = generateTtp(); diff --git a/template.tpl b/template.tpl index 6cbf860..ca9f84b 100644 --- a/template.tpl +++ b/template.tpl @@ -646,10 +646,12 @@ if (url && url.lastIndexOf('https://gtm-msr.appspot.com/', 0) === 0) { return data.gtmOnSuccess(); } -let ttclid = getCookieValues('ttclid')[0]; +const commonCookie = eventData.common_cookie || {}; + +let ttclid = getCookieValues('ttclid')[0] || commonCookie.ttclid; if (!ttclid) ttclid = eventData.ttclid; -let ttp = getCookieValues('_ttp')[0]; +let ttp = getCookieValues('_ttp')[0] || commonCookie._ttp; if (!ttp) ttp = eventData._ttp; if (!ttp && data.generateTtp) { ttp = generateTtp();