@leancodepl/gtag 9.6.4 → 9.6.6
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 +15 -15
- package/index.cjs.js +2 -2
- package/index.esm.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,34 +23,34 @@ Creates a type-safe Google Tag Manager data layer push function.
|
|
|
23
23
|
### Basic Event Tracking
|
|
24
24
|
|
|
25
25
|
```typescript
|
|
26
|
-
import { mkgtag } from
|
|
26
|
+
import { mkgtag } from "@leancodepl/gtag"
|
|
27
27
|
|
|
28
|
-
const gtag = mkgtag<{ event:
|
|
28
|
+
const gtag = mkgtag<{ event: "page_view"; page_title: string }>()
|
|
29
29
|
|
|
30
30
|
gtag({
|
|
31
|
-
event:
|
|
32
|
-
page_title:
|
|
33
|
-
})
|
|
31
|
+
event: "page_view",
|
|
32
|
+
page_title: "Home Page",
|
|
33
|
+
})
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
### Custom Events with Callbacks
|
|
37
37
|
|
|
38
38
|
```typescript
|
|
39
|
-
import { mkgtag } from
|
|
39
|
+
import { mkgtag } from "@leancodepl/gtag"
|
|
40
40
|
|
|
41
41
|
interface CustomEvent {
|
|
42
|
-
event:
|
|
43
|
-
element_id: string
|
|
42
|
+
event: "button_click"
|
|
43
|
+
element_id: string
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
const gtag = mkgtag<CustomEvent>()
|
|
46
|
+
const gtag = mkgtag<CustomEvent>()
|
|
47
47
|
|
|
48
48
|
gtag({
|
|
49
|
-
event:
|
|
50
|
-
element_id:
|
|
51
|
-
eventCallback:
|
|
52
|
-
console.log(
|
|
49
|
+
event: "button_click",
|
|
50
|
+
element_id: "signup-button",
|
|
51
|
+
eventCallback: containerId => {
|
|
52
|
+
console.log("Event sent to container:", containerId)
|
|
53
53
|
},
|
|
54
54
|
eventTimeout: 2000,
|
|
55
|
-
})
|
|
56
|
-
```
|
|
55
|
+
})
|
|
56
|
+
```
|
package/index.cjs.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Creates a type-safe Google Tag Manager data layer push function.
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* Returns a function that pushes events to the GTM data layer with type safety.
|
|
7
7
|
* Handles cases where GTM is not initialized by safely checking for dataLayer existence.
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
9
|
* @template T - Event object type extending { event: string }
|
|
10
10
|
* @returns Function that accepts data layer arguments and pushes to GTM
|
|
11
11
|
* @example
|
package/index.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Creates a type-safe Google Tag Manager data layer push function.
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* Returns a function that pushes events to the GTM data layer with type safety.
|
|
5
5
|
* Handles cases where GTM is not initialized by safely checking for dataLayer existence.
|
|
6
|
-
*
|
|
6
|
+
*
|
|
7
7
|
* @template T - Event object type extending { event: string }
|
|
8
8
|
* @returns Function that accepts data layer arguments and pushes to GTM
|
|
9
9
|
* @example
|