Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all event set the gcl_aw cookie, simplify code #7

Merged
merged 4 commits into from
Jul 16, 2024
Merged

Conversation

ad-astra-via
Copy link
Contributor

No description provided.

// search for _gl param used for cross-domain tracking, and extract the _gcl_aw cookie value from it
try {
const ts = Math.floor(new Date().valueOf() / 1000)
if (client.url.searchParams.get('_gl')) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bjesus @simonabadoiu I took the liberty to change how we extract the value from _gl. Previously we were doing:

if (client.url.searchParams.get('_gl')) { try { const gclaw = atob( (client.url.searchParams.get('_gl')?.split('*').pop() || '').replaceAll( '.', '' ) ) client.set('_gcl_aw', gclaw, { scope: 'infinite', }) query.gclaw = gclaw.split('.').pop() } catch (e) { console.error('Google Conversion Pixel: Error parsing gclaw') console.error(e) } }

Testing of cross domain traffic reveals that the structure of the _gl is different. This parameter chains values of different cookies, only one of the is '_gcl_aw'. For example, it could be:

'_gl=1159xsr_ga_N5L9GMND5MTYzNTENjQzMC40MS4xLjE2MzU×NTkMTguMA_fp|c*/VozZE1zRk16cjBOcVIJ*_gcl_awCjwKCAjwnK60BhA9EiwAmpHZwxKOtYkUL7L3fXNGpGSuGAY8b9UwJSUBKiAO569CG3wPjFzGvtEcVRoCrVwQAvD_BwE'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simonabadoiu simonabadoiu requested review from simonabadoiu and removed request for simonabadoiu July 9, 2024 15:39
@ad-astra-via ad-astra-via merged commit da07270 into main Jul 16, 2024
1 check passed
@ad-astra-via ad-astra-via deleted the gclid-fix branch July 16, 2024 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants