diff --git a/metadata.yaml b/metadata.yaml index 5b5f770..73ca33d 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -1,5 +1,7 @@ homepage: "https://stape.io/" versions: + - sha: 3639d997b1a2d25404a82ddaa428e6af05aba1c0 + changeNotes: Added common cookie support. - sha: b0cb2a6c643dd0b5baea1db3d382a1f7bb3bb546 changeNotes: Added missing userData fields. - sha: 1b2f1fc426f1a7265d462007563cf0861d6600e8 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();