@walkeros/web-destination-gtag 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -2
- package/dist/examples/index.d.mts +40 -11
- package/dist/examples/index.d.ts +40 -11
- package/dist/examples/index.js +5439 -34
- package/dist/examples/index.mjs +5438 -34
- package/dist/index.browser.js +1 -1
- package/dist/index.d.mts +53 -9
- package/dist/index.d.ts +53 -9
- package/dist/index.es5.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -28,10 +28,10 @@ npm install @walkeros/web-destination-gtag
|
|
|
28
28
|
## Usage
|
|
29
29
|
|
|
30
30
|
```typescript
|
|
31
|
-
import {
|
|
31
|
+
import { startFlow } from '@walkeros/collector';
|
|
32
32
|
import { destinationGtag } from '@walkeros/web-destination-gtag';
|
|
33
33
|
|
|
34
|
-
const { elb } = await
|
|
34
|
+
const { elb } = await startFlow();
|
|
35
35
|
|
|
36
36
|
elb('walker destination', destinationGtag, {
|
|
37
37
|
settings: {
|
|
@@ -66,6 +66,60 @@ For custom event mapping (`mapping.entity.action.settings`):
|
|
|
66
66
|
| `ads` | `AdsMapping` | Google Ads specific event mapping configuration | No | `{ label: 'conversion_label' }` |
|
|
67
67
|
| `gtm` | `GTMMapping` | GTM specific event mapping configuration | No | `{}` |
|
|
68
68
|
|
|
69
|
+
## Consent Mode
|
|
70
|
+
|
|
71
|
+
The gtag destination automatically handles Google Consent Mode v2 with a "deny
|
|
72
|
+
by default" approach. Configure consent mode using the `como` setting:
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { destinationGtag } from '@walkeros/web-destination-gtag';
|
|
76
|
+
|
|
77
|
+
const destination = destinationGtag({
|
|
78
|
+
settings: {
|
|
79
|
+
como: true, // Enable with default mapping
|
|
80
|
+
ga4: { measurementId: 'G-XXXXXXXXXX' },
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Configuration Options
|
|
86
|
+
|
|
87
|
+
| Value | Description | Default Mapping |
|
|
88
|
+
| -------- | -------------------- | ------------------------------------------------------------------------------------------------------ |
|
|
89
|
+
| `false` | Disable consent mode | - |
|
|
90
|
+
| `true` | Use default mapping | `marketing` → `ad_storage`, `ad_user_data`, `ad_personalization`<br>`functional` → `analytics_storage` |
|
|
91
|
+
| `object` | Custom mapping | `{ [walkerOSGroup]: gtagParameter \| gtagParameter[] }` |
|
|
92
|
+
|
|
93
|
+
### Custom Mapping
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
const destination = destinationGtag({
|
|
97
|
+
settings: {
|
|
98
|
+
como: {
|
|
99
|
+
marketing: ['ad_storage', 'ad_personalization'],
|
|
100
|
+
analytics: 'analytics_storage',
|
|
101
|
+
},
|
|
102
|
+
ga4: { measurementId: 'G-XXXXXXXXXX' },
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Usage
|
|
108
|
+
|
|
109
|
+
Consent mode automatically activates when you send consent events through
|
|
110
|
+
walkerOS:
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
// Grant consent
|
|
114
|
+
elb('walker consent', { marketing: true, functional: true });
|
|
115
|
+
|
|
116
|
+
// Deny consent
|
|
117
|
+
elb('walker consent', { marketing: false, functional: false });
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
The destination handles all gtag consent calls automatically, ensuring
|
|
121
|
+
compliance with privacy regulations.
|
|
122
|
+
|
|
69
123
|
## Examples
|
|
70
124
|
|
|
71
125
|
### E-commerce Purchase
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import { Mapping as Mapping$1 } from '@walkeros/core';
|
|
2
|
-
|
|
3
|
-
declare function ga4Purchase$1(): unknown[];
|
|
4
|
-
declare function ga4AddToCart$1(): unknown[];
|
|
5
|
-
declare function adsConversion$1(): unknown[];
|
|
6
|
-
declare function gtmEvent(): Record<string, unknown>;
|
|
7
|
-
|
|
8
|
-
declare const events_gtmEvent: typeof gtmEvent;
|
|
9
|
-
declare namespace events {
|
|
10
|
-
export { adsConversion$1 as adsConversion, ga4AddToCart$1 as ga4AddToCart, ga4Purchase$1 as ga4Purchase, events_gtmEvent as gtmEvent };
|
|
11
|
-
}
|
|
2
|
+
import { DestinationWeb } from '@walkeros/web-core';
|
|
12
3
|
|
|
13
4
|
declare global {
|
|
14
5
|
interface Window {
|
|
@@ -16,6 +7,23 @@ declare global {
|
|
|
16
7
|
[key: string]: unknown;
|
|
17
8
|
}
|
|
18
9
|
}
|
|
10
|
+
interface Env extends DestinationWeb.Env {
|
|
11
|
+
window: {
|
|
12
|
+
gtag: Gtag.Gtag;
|
|
13
|
+
dataLayer: unknown[];
|
|
14
|
+
};
|
|
15
|
+
document: {
|
|
16
|
+
createElement: (tagName: string) => {
|
|
17
|
+
src: string;
|
|
18
|
+
async?: boolean;
|
|
19
|
+
setAttribute: (name: string, value: string) => void;
|
|
20
|
+
removeAttribute: (name: string) => void;
|
|
21
|
+
};
|
|
22
|
+
head: {
|
|
23
|
+
appendChild: (node: unknown) => void;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}
|
|
19
27
|
interface AdsMapping {
|
|
20
28
|
label?: string;
|
|
21
29
|
}
|
|
@@ -32,6 +40,27 @@ interface GTMMapping {
|
|
|
32
40
|
type Rule = Mapping$1.Rule<Mapping>;
|
|
33
41
|
type Include = Array<'all' | 'context' | 'data' | 'event' | 'globals' | 'source' | 'user' | 'version'>;
|
|
34
42
|
|
|
43
|
+
declare const init: Env | undefined;
|
|
44
|
+
declare const push: Env;
|
|
45
|
+
declare const simulation: string[];
|
|
46
|
+
|
|
47
|
+
declare const env_init: typeof init;
|
|
48
|
+
declare const env_push: typeof push;
|
|
49
|
+
declare const env_simulation: typeof simulation;
|
|
50
|
+
declare namespace env {
|
|
51
|
+
export { env_init as init, env_push as push, env_simulation as simulation };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
declare function ga4Purchase$1(): unknown[];
|
|
55
|
+
declare function ga4AddToCart$1(): unknown[];
|
|
56
|
+
declare function adsConversion$1(): unknown[];
|
|
57
|
+
declare function gtmEvent(): Record<string, unknown>;
|
|
58
|
+
|
|
59
|
+
declare const events_gtmEvent: typeof gtmEvent;
|
|
60
|
+
declare namespace events {
|
|
61
|
+
export { adsConversion$1 as adsConversion, ga4AddToCart$1 as ga4AddToCart, ga4Purchase$1 as ga4Purchase, events_gtmEvent as gtmEvent };
|
|
62
|
+
}
|
|
63
|
+
|
|
35
64
|
declare const ga4Purchase: Rule;
|
|
36
65
|
declare const ga4AddToCart: Rule;
|
|
37
66
|
declare const adsConversion: Rule;
|
|
@@ -57,4 +86,4 @@ declare namespace mapping {
|
|
|
57
86
|
export { mapping_adsConversion as adsConversion, mapping_combinedPurchase as combinedPurchase, mapping_config as config, mapping_ga4AddToCart as ga4AddToCart, mapping_ga4Purchase as ga4Purchase, mapping_gtmProductView as gtmProductView };
|
|
58
87
|
}
|
|
59
88
|
|
|
60
|
-
export { events, mapping };
|
|
89
|
+
export { env, events, mapping };
|
package/dist/examples/index.d.ts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import { Mapping as Mapping$1 } from '@walkeros/core';
|
|
2
|
-
|
|
3
|
-
declare function ga4Purchase$1(): unknown[];
|
|
4
|
-
declare function ga4AddToCart$1(): unknown[];
|
|
5
|
-
declare function adsConversion$1(): unknown[];
|
|
6
|
-
declare function gtmEvent(): Record<string, unknown>;
|
|
7
|
-
|
|
8
|
-
declare const events_gtmEvent: typeof gtmEvent;
|
|
9
|
-
declare namespace events {
|
|
10
|
-
export { adsConversion$1 as adsConversion, ga4AddToCart$1 as ga4AddToCart, ga4Purchase$1 as ga4Purchase, events_gtmEvent as gtmEvent };
|
|
11
|
-
}
|
|
2
|
+
import { DestinationWeb } from '@walkeros/web-core';
|
|
12
3
|
|
|
13
4
|
declare global {
|
|
14
5
|
interface Window {
|
|
@@ -16,6 +7,23 @@ declare global {
|
|
|
16
7
|
[key: string]: unknown;
|
|
17
8
|
}
|
|
18
9
|
}
|
|
10
|
+
interface Env extends DestinationWeb.Env {
|
|
11
|
+
window: {
|
|
12
|
+
gtag: Gtag.Gtag;
|
|
13
|
+
dataLayer: unknown[];
|
|
14
|
+
};
|
|
15
|
+
document: {
|
|
16
|
+
createElement: (tagName: string) => {
|
|
17
|
+
src: string;
|
|
18
|
+
async?: boolean;
|
|
19
|
+
setAttribute: (name: string, value: string) => void;
|
|
20
|
+
removeAttribute: (name: string) => void;
|
|
21
|
+
};
|
|
22
|
+
head: {
|
|
23
|
+
appendChild: (node: unknown) => void;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}
|
|
19
27
|
interface AdsMapping {
|
|
20
28
|
label?: string;
|
|
21
29
|
}
|
|
@@ -32,6 +40,27 @@ interface GTMMapping {
|
|
|
32
40
|
type Rule = Mapping$1.Rule<Mapping>;
|
|
33
41
|
type Include = Array<'all' | 'context' | 'data' | 'event' | 'globals' | 'source' | 'user' | 'version'>;
|
|
34
42
|
|
|
43
|
+
declare const init: Env | undefined;
|
|
44
|
+
declare const push: Env;
|
|
45
|
+
declare const simulation: string[];
|
|
46
|
+
|
|
47
|
+
declare const env_init: typeof init;
|
|
48
|
+
declare const env_push: typeof push;
|
|
49
|
+
declare const env_simulation: typeof simulation;
|
|
50
|
+
declare namespace env {
|
|
51
|
+
export { env_init as init, env_push as push, env_simulation as simulation };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
declare function ga4Purchase$1(): unknown[];
|
|
55
|
+
declare function ga4AddToCart$1(): unknown[];
|
|
56
|
+
declare function adsConversion$1(): unknown[];
|
|
57
|
+
declare function gtmEvent(): Record<string, unknown>;
|
|
58
|
+
|
|
59
|
+
declare const events_gtmEvent: typeof gtmEvent;
|
|
60
|
+
declare namespace events {
|
|
61
|
+
export { adsConversion$1 as adsConversion, ga4AddToCart$1 as ga4AddToCart, ga4Purchase$1 as ga4Purchase, events_gtmEvent as gtmEvent };
|
|
62
|
+
}
|
|
63
|
+
|
|
35
64
|
declare const ga4Purchase: Rule;
|
|
36
65
|
declare const ga4AddToCart: Rule;
|
|
37
66
|
declare const adsConversion: Rule;
|
|
@@ -57,4 +86,4 @@ declare namespace mapping {
|
|
|
57
86
|
export { mapping_adsConversion as adsConversion, mapping_combinedPurchase as combinedPurchase, mapping_config as config, mapping_ga4AddToCart as ga4AddToCart, mapping_ga4Purchase as ga4Purchase, mapping_gtmProductView as gtmProductView };
|
|
58
87
|
}
|
|
59
88
|
|
|
60
|
-
export { events, mapping };
|
|
89
|
+
export { env, events, mapping };
|