From 5bce3c41560e1c33b1b0f581343332e1547c2047 Mon Sep 17 00:00:00 2001 From: indy koning Date: Mon, 22 Apr 2024 15:54:48 +0200 Subject: [PATCH 1/5] Support tag assistant debugger in Partytown --- resources/views/partytown/config.blade.php | 64 +++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/resources/views/partytown/config.blade.php b/resources/views/partytown/config.blade.php index 94e8a8a..9517fa5 100644 --- a/resources/views/partytown/config.blade.php +++ b/resources/views/partytown/config.blade.php @@ -1,7 +1,50 @@ @once +@if(config('rapidez.gtm.partytown.enabled')) + +@endif @endonce From 1f37b12559aa021d5ed7c4f16341d5a2c21a8944 Mon Sep 17 00:00:00 2001 From: indy koning Date: Mon, 22 Apr 2024 16:51:33 +0200 Subject: [PATCH 2/5] Move config --- resources/views/partytown/config.blade.php | 82 +++++++++++----------- 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/resources/views/partytown/config.blade.php b/resources/views/partytown/config.blade.php index 9517fa5..1dc388b 100644 --- a/resources/views/partytown/config.blade.php +++ b/resources/views/partytown/config.blade.php @@ -1,47 +1,5 @@ @once @if(config('rapidez.gtm.partytown.enabled')) From 7fefa94559bed02ca8c6b28f7c85efb69d48511b Mon Sep 17 00:00:00 2001 From: indy koning Date: Mon, 22 Apr 2024 16:52:26 +0200 Subject: [PATCH 3/5] Move config --- resources/views/partytown/config.blade.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/views/partytown/config.blade.php b/resources/views/partytown/config.blade.php index 1dc388b..ea8e830 100644 --- a/resources/views/partytown/config.blade.php +++ b/resources/views/partytown/config.blade.php @@ -14,11 +14,12 @@ @if(config('rapidez.gtm.partytown.enabled')) partytown.forward.push(['dataLayer.push', { preserveBehavior: true }]); - partytown.forward.push('__tag_assistant_forwarder'); - partytown.mainWindowAccessors.push('__tag_assistant_accessor'); if (window.__TAG_ASSISTANT_API !== undefined) { // Tag assistant compatibility + partytown.forward.push('__tag_assistant_forwarder'); + partytown.mainWindowAccessors.push('__tag_assistant_accessor'); + const gtmDebugLog = (msg, data) => { if (window.partytown.debug) { console.debug( From 74a438159c1ede307edf949e32bc90a63ab8881a Mon Sep 17 00:00:00 2001 From: indykoning <15870933+indykoning@users.noreply.github.com> Date: Fri, 3 May 2024 14:12:35 +0200 Subject: [PATCH 4/5] Add latest fixes --- resources/views/partytown/config.blade.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/resources/views/partytown/config.blade.php b/resources/views/partytown/config.blade.php index ea8e830..efb5115 100644 --- a/resources/views/partytown/config.blade.php +++ b/resources/views/partytown/config.blade.php @@ -9,13 +9,18 @@ return @json(route('rapidez-gtm::proxy', ['url' => '/'], false) . '/') + url.href; } return url - } + }, + resolveSendBeaconRequestParameters: function (url) { + return url.hostname.includes('analytics.google') || url.hostname.includes('google-analytics') + ? { keepalive: false } + : {}; + }, } @if(config('rapidez.gtm.partytown.enabled')) partytown.forward.push(['dataLayer.push', { preserveBehavior: true }]); - if (window.__TAG_ASSISTANT_API !== undefined) { + if ({{ request()->has('gtm_debug') }} || window.__TAG_ASSISTANT_API !== undefined) { // Tag assistant compatibility partytown.forward.push('__tag_assistant_forwarder'); partytown.mainWindowAccessors.push('__tag_assistant_accessor'); @@ -31,7 +36,7 @@ } } - __tag_assistant_accessor = { + window.__tag_assistant_accessor = { receiver: function(...args) { window.__tag_assistant_forwarder.apply(null, arguments); }, From aa09aa5938df43d88b0528a40da1b81f4217fe15 Mon Sep 17 00:00:00 2001 From: indykoning <15870933+indykoning@users.noreply.github.com> Date: Wed, 15 May 2024 16:07:35 +0200 Subject: [PATCH 5/5] Explicitly return true or false --- resources/views/partytown/config.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/partytown/config.blade.php b/resources/views/partytown/config.blade.php index efb5115..4d88d19 100644 --- a/resources/views/partytown/config.blade.php +++ b/resources/views/partytown/config.blade.php @@ -20,7 +20,7 @@ @if(config('rapidez.gtm.partytown.enabled')) partytown.forward.push(['dataLayer.push', { preserveBehavior: true }]); - if ({{ request()->has('gtm_debug') }} || window.__TAG_ASSISTANT_API !== undefined) { + if ({{ request()->has('gtm_debug') ? 'true' : 'false' }} || window.__TAG_ASSISTANT_API !== undefined) { // Tag assistant compatibility partytown.forward.push('__tag_assistant_forwarder'); partytown.mainWindowAccessors.push('__tag_assistant_accessor');