From da782651fdb9b5054149e7e00da5ca2e160c3499 Mon Sep 17 00:00:00 2001 From: Thorsten Kober Date: Sun, 21 Jul 2024 20:32:32 -0700 Subject: [PATCH 1/7] remove window.gtag --- src/third-parties/google-analytics/data.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/third-parties/google-analytics/data.json b/src/third-parties/google-analytics/data.json index 0620ccd..d3575a4 100644 --- a/src/third-parties/google-analytics/data.json +++ b/src/third-parties/google-analytics/data.json @@ -12,7 +12,7 @@ "key": "gtag" }, { - "code": "window.dataLayers=window.dataLayers||{};window.dataLayers['{{dataLayerName}}']=window.dataLayers['{{dataLayerName}}']||[];window.gtag=function gtag(){window.dataLayers['{{dataLayerName}}'].push(arguments);};window.gtag('js',new Date());window.gtag('config','{{id}}')", + "code": "window.dataLayers=window.dataLayers||{};window.dataLayers['{{dataLayerName}}']=window.dataLayers['{{dataLayerName}}']||[];window.dataLayers['{{dataLayerName}}'].push({'js':new Date()});window.dataLayers['{{dataLayerName}}'].push({'config':'{{id}}'})", "params": ["id", "dataLayerName"], "strategy": "worker", "location": "head", From e07d849898588038eb84513e8aca63e7d9acdaf2 Mon Sep 17 00:00:00 2001 From: Thorsten Kober Date: Mon, 22 Jul 2024 11:15:24 -0700 Subject: [PATCH 2/7] remove gtag type --- src/types/type-declarations.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/types/type-declarations.ts b/src/types/type-declarations.ts index c6489f0..db0cda2 100644 --- a/src/types/type-declarations.ts +++ b/src/types/type-declarations.ts @@ -77,7 +77,6 @@ export interface GTag { export interface GoogleAnalyticsApi { dataLayers: Record[]>; - gtag: GTag; } /* Google Tag Manager */ From c0406abf6d1615005c5b033b170903dd58588f11 Mon Sep 17 00:00:00 2001 From: Thorsten Kober Date: Mon, 22 Jul 2024 16:14:40 -0700 Subject: [PATCH 3/7] updates --- src/third-parties/google-analytics/data.json | 6 +++--- src/third-parties/google-tag-manager/data.json | 6 +++--- src/types/type-declarations.ts | 16 +++++++++++++--- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/third-parties/google-analytics/data.json b/src/third-parties/google-analytics/data.json index d3575a4..12c8a48 100644 --- a/src/third-parties/google-analytics/data.json +++ b/src/third-parties/google-analytics/data.json @@ -5,15 +5,15 @@ "scripts": [ { "url": "https://www.googletagmanager.com/gtag/js", - "params": ["id"], + "params": ["id", "l"], "strategy": "worker", "location": "head", "action": "append", "key": "gtag" }, { - "code": "window.dataLayers=window.dataLayers||{};window.dataLayers['{{dataLayerName}}']=window.dataLayers['{{dataLayerName}}']||[];window.dataLayers['{{dataLayerName}}'].push({'js':new Date()});window.dataLayers['{{dataLayerName}}'].push({'config':'{{id}}'})", - "params": ["id", "dataLayerName"], + "code": "window['{{l}}']=window['{{l}}']||[];window['{{l}}'].push({'js':new Date()});window['{{l}}'].push({'config':'{{id}}'})", + "params": ["id", "l"], "strategy": "worker", "location": "head", "action": "append", diff --git a/src/third-parties/google-tag-manager/data.json b/src/third-parties/google-tag-manager/data.json index 16f31be..757afbf 100644 --- a/src/third-parties/google-tag-manager/data.json +++ b/src/third-parties/google-tag-manager/data.json @@ -5,15 +5,15 @@ "scripts": [ { "url": "https://www.googletagmanager.com/gtm.js", - "params": ["id"], + "params": ["id", "l"], "strategy": "worker", "location": "head", "action": "append", "key": "gtm" }, { - "code": "window.dataLayers=window.dataLayers||{};window.dataLayers['{{dataLayerName}}']=window.dataLayers['{{dataLayerName}}']||[];window.dataLayers['{{dataLayerName}}'].push({'gtm.start':new Date().getTime(),event:'gtm.js'});", - "params": ["dataLayerName"], + "code": "window['{{l}}']=window['{{l}}']||[];window['{{l}}'].push({'gtm.start':new Date().getTime(),event:'gtm.js'});", + "params": ["l"], "strategy": "worker", "location": "head", "action": "append", diff --git a/src/types/type-declarations.ts b/src/types/type-declarations.ts index db0cda2..b32a7c0 100644 --- a/src/types/type-declarations.ts +++ b/src/types/type-declarations.ts @@ -62,6 +62,10 @@ export interface Output { /* Google Analytics */ export interface GoogleAnalyticsParams { id: string; + /** + * The name of the dataLayer object. Defaults to 'dataLayer'. + */ + l?: string; } export interface GTag { @@ -75,13 +79,20 @@ export interface GTag { (fn: 'config', opt: 'reset'): void; } +export type DataLayer = Record[]; +export type Maybe = NonNullable | undefined; + export interface GoogleAnalyticsApi { - dataLayers: Record[]>; + [key: string]: Maybe; } /* Google Tag Manager */ export interface GoogleTagManagerParams { id: string; + /** + * The name of the dataLayer object. Defaults to 'dataLayer'. + */ + l?: string; } interface GoogleTagManagerDataLayerApi { @@ -107,8 +118,7 @@ export type GoogleTagManager = GoogleTagManagerDataLayerStatus & { }; export interface GoogleTagManagerApi { - dataLayers: Record[]>; - google_tag_manager: GoogleTagManager; + [key: string]: Maybe | Maybe; } /* Google Maps Embed */ From 4b047a1925bc6978a3273e0e569da3e6b3c97826 Mon Sep 17 00:00:00 2001 From: Thorsten Kober Date: Tue, 23 Jul 2024 08:54:49 -0700 Subject: [PATCH 4/7] adjust type name --- src/types/type-declarations.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types/type-declarations.ts b/src/types/type-declarations.ts index b32a7c0..5c34590 100644 --- a/src/types/type-declarations.ts +++ b/src/types/type-declarations.ts @@ -110,7 +110,7 @@ type GoogleTagManagerDataLayerStatus = { }; }; -export type GoogleTagManager = GoogleTagManagerDataLayerStatus & { +export type GoogleTagManagerInstance = GoogleTagManagerDataLayerStatus & { [key: string]: { callback: () => void; dataLayer: GoogleTagManagerDataLayerApi; @@ -118,7 +118,7 @@ export type GoogleTagManager = GoogleTagManagerDataLayerStatus & { }; export interface GoogleTagManagerApi { - [key: string]: Maybe | Maybe; + [key: string]: Maybe | Maybe; } /* Google Maps Embed */ From 10057adda76c5adcde2c21cc2c07869461bba9bb Mon Sep 17 00:00:00 2001 From: Thorsten Kober Date: Tue, 23 Jul 2024 11:29:57 -0700 Subject: [PATCH 5/7] pr feedback --- src/types/type-declarations.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/types/type-declarations.ts b/src/types/type-declarations.ts index 5c34590..90399fe 100644 --- a/src/types/type-declarations.ts +++ b/src/types/type-declarations.ts @@ -79,12 +79,7 @@ export interface GTag { (fn: 'config', opt: 'reset'): void; } -export type DataLayer = Record[]; -export type Maybe = NonNullable | undefined; - -export interface GoogleAnalyticsApi { - [key: string]: Maybe; -} +export interface GoogleAnalyticsApi {} /* Google Tag Manager */ export interface GoogleTagManagerParams { @@ -118,7 +113,7 @@ export type GoogleTagManagerInstance = GoogleTagManagerDataLayerStatus & { }; export interface GoogleTagManagerApi { - [key: string]: Maybe | Maybe; + google_tag_manager: GoogleTagManagerInstance; } /* Google Maps Embed */ From 86e607d70dc6024d806c0f0a471445fc1b1d221f Mon Sep 17 00:00:00 2001 From: Thorsten Kober Date: Tue, 23 Jul 2024 12:02:35 -0700 Subject: [PATCH 6/7] export DataLayer --- src/types/type-declarations.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/types/type-declarations.ts b/src/types/type-declarations.ts index 90399fe..fb50293 100644 --- a/src/types/type-declarations.ts +++ b/src/types/type-declarations.ts @@ -79,6 +79,8 @@ export interface GTag { (fn: 'config', opt: 'reset'): void; } +export type DataLayer = Record[]; + export interface GoogleAnalyticsApi {} /* Google Tag Manager */ From 6204d1b447e74a9984c2d38490bcd7a17df79dba Mon Sep 17 00:00:00 2001 From: Thorsten Kober Date: Wed, 24 Jul 2024 00:00:14 -0700 Subject: [PATCH 7/7] remove empty type --- src/types/type-declarations.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/types/type-declarations.ts b/src/types/type-declarations.ts index fb50293..76dbd09 100644 --- a/src/types/type-declarations.ts +++ b/src/types/type-declarations.ts @@ -81,8 +81,6 @@ export interface GTag { export type DataLayer = Record[]; -export interface GoogleAnalyticsApi {} - /* Google Tag Manager */ export interface GoogleTagManagerParams { id: string;