@jwiedeman/gtm-kit-solid 1.1.1 → 1.1.3
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 +51 -54
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @jwiedeman/gtm-kit-solid
|
|
2
2
|
|
|
3
3
|
[](https://github.com/jwiedeman/react-gtm-kit/actions/workflows/ci.yml)
|
|
4
4
|
[](https://codecov.io/gh/jwiedeman/react-gtm-kit)
|
|
5
|
-
[](https://www.npmjs.com/package/@jwiedeman/gtm-kit-solid)
|
|
6
|
+
[](https://bundlephobia.com/package/@jwiedeman/gtm-kit-solid)
|
|
7
7
|
[](https://www.typescriptlang.org/)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
9
9
|
[](https://www.solidjs.com/)
|
|
@@ -17,15 +17,15 @@ The SolidJS adapter for GTM Kit - provides context and hooks for idiomatic Solid
|
|
|
17
17
|
## Installation
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
npm install @
|
|
20
|
+
npm install @jwiedeman/gtm-kit @jwiedeman/gtm-kit-solid
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
yarn add @
|
|
24
|
+
yarn add @jwiedeman/gtm-kit @jwiedeman/gtm-kit-solid
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
pnpm add @
|
|
28
|
+
pnpm add @jwiedeman/gtm-kit @jwiedeman/gtm-kit-solid
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
---
|
|
@@ -36,7 +36,7 @@ pnpm add @react-gtm-kit/core @react-gtm-kit/solid
|
|
|
36
36
|
|
|
37
37
|
```tsx
|
|
38
38
|
// App.tsx
|
|
39
|
-
import { GtmProvider } from '@
|
|
39
|
+
import { GtmProvider } from '@jwiedeman/gtm-kit-solid';
|
|
40
40
|
|
|
41
41
|
function App() {
|
|
42
42
|
return (
|
|
@@ -50,16 +50,12 @@ function App() {
|
|
|
50
50
|
### Step 2: Push Events
|
|
51
51
|
|
|
52
52
|
```tsx
|
|
53
|
-
import { useGtmPush } from '@
|
|
53
|
+
import { useGtmPush } from '@jwiedeman/gtm-kit-solid';
|
|
54
54
|
|
|
55
55
|
function BuyButton() {
|
|
56
56
|
const push = useGtmPush();
|
|
57
57
|
|
|
58
|
-
return (
|
|
59
|
-
<button onClick={() => push({ event: 'purchase', value: 49.99 })}>
|
|
60
|
-
Buy Now
|
|
61
|
-
</button>
|
|
62
|
-
);
|
|
58
|
+
return <button onClick={() => push({ event: 'purchase', value: 49.99 })}>Buy Now</button>;
|
|
63
59
|
}
|
|
64
60
|
```
|
|
65
61
|
|
|
@@ -69,14 +65,14 @@ function BuyButton() {
|
|
|
69
65
|
|
|
70
66
|
## Features
|
|
71
67
|
|
|
72
|
-
| Feature
|
|
73
|
-
|
|
74
|
-
| **SolidJS Native**
|
|
75
|
-
| **Fine-Grained**
|
|
76
|
-
| **Context-Based**
|
|
77
|
-
| **TypeScript**
|
|
78
|
-
| **Consent Mode v2** | Built-in GDPR compliance
|
|
79
|
-
| **SSR Compatible**
|
|
68
|
+
| Feature | Description |
|
|
69
|
+
| ------------------- | ----------------------------------- |
|
|
70
|
+
| **SolidJS Native** | Built for Solid's reactivity system |
|
|
71
|
+
| **Fine-Grained** | Only updates what needs to update |
|
|
72
|
+
| **Context-Based** | Uses Solid's context API |
|
|
73
|
+
| **TypeScript** | Full type definitions included |
|
|
74
|
+
| **Consent Mode v2** | Built-in GDPR compliance |
|
|
75
|
+
| **SSR Compatible** | Safe for SolidStart SSR |
|
|
80
76
|
|
|
81
77
|
---
|
|
82
78
|
|
|
@@ -87,7 +83,7 @@ function BuyButton() {
|
|
|
87
83
|
Get the full GTM context.
|
|
88
84
|
|
|
89
85
|
```tsx
|
|
90
|
-
import { useGtm } from '@
|
|
86
|
+
import { useGtm } from '@jwiedeman/gtm-kit-solid';
|
|
91
87
|
|
|
92
88
|
function MyComponent() {
|
|
93
89
|
const { push, client, updateConsent, initialized } = useGtm();
|
|
@@ -106,16 +102,12 @@ function MyComponent() {
|
|
|
106
102
|
Get just the push function.
|
|
107
103
|
|
|
108
104
|
```tsx
|
|
109
|
-
import { useGtmPush } from '@
|
|
105
|
+
import { useGtmPush } from '@jwiedeman/gtm-kit-solid';
|
|
110
106
|
|
|
111
107
|
function MyComponent() {
|
|
112
108
|
const push = useGtmPush();
|
|
113
109
|
|
|
114
|
-
return (
|
|
115
|
-
<button onClick={() => push({ event: 'purchase', value: 99 })}>
|
|
116
|
-
Buy
|
|
117
|
-
</button>
|
|
118
|
-
);
|
|
110
|
+
return <button onClick={() => push({ event: 'purchase', value: 99 })}>Buy</button>;
|
|
119
111
|
}
|
|
120
112
|
```
|
|
121
113
|
|
|
@@ -124,7 +116,7 @@ function MyComponent() {
|
|
|
124
116
|
Access consent management functions.
|
|
125
117
|
|
|
126
118
|
```tsx
|
|
127
|
-
import { useGtmConsent } from '@
|
|
119
|
+
import { useGtmConsent } from '@jwiedeman/gtm-kit-solid';
|
|
128
120
|
|
|
129
121
|
function CookieBanner() {
|
|
130
122
|
const { updateConsent } = useGtmConsent();
|
|
@@ -147,7 +139,7 @@ function CookieBanner() {
|
|
|
147
139
|
Get the raw GTM client instance.
|
|
148
140
|
|
|
149
141
|
```tsx
|
|
150
|
-
import { useGtmClient } from '@
|
|
142
|
+
import { useGtmClient } from '@jwiedeman/gtm-kit-solid';
|
|
151
143
|
|
|
152
144
|
function MyComponent() {
|
|
153
145
|
const client = useGtmClient();
|
|
@@ -161,7 +153,7 @@ function MyComponent() {
|
|
|
161
153
|
Get a function that resolves when GTM is loaded.
|
|
162
154
|
|
|
163
155
|
```tsx
|
|
164
|
-
import { useGtmReady } from '@
|
|
156
|
+
import { useGtmReady } from '@jwiedeman/gtm-kit-solid';
|
|
165
157
|
import { onMount } from 'solid-js';
|
|
166
158
|
|
|
167
159
|
function MyComponent() {
|
|
@@ -206,7 +198,7 @@ function MyComponent() {
|
|
|
206
198
|
|
|
207
199
|
```tsx
|
|
208
200
|
// src/root.tsx
|
|
209
|
-
import { GtmProvider } from '@
|
|
201
|
+
import { GtmProvider } from '@jwiedeman/gtm-kit-solid';
|
|
210
202
|
|
|
211
203
|
export default function Root() {
|
|
212
204
|
return (
|
|
@@ -225,7 +217,7 @@ export default function Root() {
|
|
|
225
217
|
### Page Tracking with Router
|
|
226
218
|
|
|
227
219
|
```tsx
|
|
228
|
-
import { useGtmPush } from '@
|
|
220
|
+
import { useGtmPush } from '@jwiedeman/gtm-kit-solid';
|
|
229
221
|
import { useLocation } from '@solidjs/router';
|
|
230
222
|
import { createEffect } from 'solid-js';
|
|
231
223
|
|
|
@@ -249,8 +241,8 @@ function PageTracker() {
|
|
|
249
241
|
## Consent Mode v2 (GDPR)
|
|
250
242
|
|
|
251
243
|
```tsx
|
|
252
|
-
import { GtmProvider, useGtmConsent } from '@
|
|
253
|
-
import { consentPresets } from '@
|
|
244
|
+
import { GtmProvider, useGtmConsent } from '@jwiedeman/gtm-kit-solid';
|
|
245
|
+
import { consentPresets } from '@jwiedeman/gtm-kit';
|
|
254
246
|
|
|
255
247
|
// In your root component
|
|
256
248
|
function App() {
|
|
@@ -275,20 +267,28 @@ function CookieBanner() {
|
|
|
275
267
|
return (
|
|
276
268
|
<div class="cookie-banner">
|
|
277
269
|
<p>We use cookies to improve your experience.</p>
|
|
278
|
-
<button
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
270
|
+
<button
|
|
271
|
+
onClick={() =>
|
|
272
|
+
updateConsent({
|
|
273
|
+
ad_storage: 'granted',
|
|
274
|
+
analytics_storage: 'granted',
|
|
275
|
+
ad_user_data: 'granted',
|
|
276
|
+
ad_personalization: 'granted'
|
|
277
|
+
})
|
|
278
|
+
}
|
|
279
|
+
>
|
|
284
280
|
Accept All
|
|
285
281
|
</button>
|
|
286
|
-
<button
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
282
|
+
<button
|
|
283
|
+
onClick={() =>
|
|
284
|
+
updateConsent({
|
|
285
|
+
ad_storage: 'denied',
|
|
286
|
+
analytics_storage: 'denied',
|
|
287
|
+
ad_user_data: 'denied',
|
|
288
|
+
ad_personalization: 'denied'
|
|
289
|
+
})
|
|
290
|
+
}
|
|
291
|
+
>
|
|
292
292
|
Reject All
|
|
293
293
|
</button>
|
|
294
294
|
</div>
|
|
@@ -302,10 +302,7 @@ function CookieBanner() {
|
|
|
302
302
|
|
|
303
303
|
```tsx
|
|
304
304
|
<GtmProvider
|
|
305
|
-
containers={[
|
|
306
|
-
{ id: 'GTM-MAIN' },
|
|
307
|
-
{ id: 'GTM-ADS', queryParams: { gtm_auth: 'abc', gtm_preview: 'env-1' } }
|
|
308
|
-
]}
|
|
305
|
+
containers={[{ id: 'GTM-MAIN' }, { id: 'GTM-ADS', queryParams: { gtm_auth: 'abc', gtm_preview: 'env-1' } }]}
|
|
309
306
|
>
|
|
310
307
|
{children}
|
|
311
308
|
</GtmProvider>
|
|
@@ -318,8 +315,8 @@ function CookieBanner() {
|
|
|
318
315
|
Full TypeScript support is included:
|
|
319
316
|
|
|
320
317
|
```tsx
|
|
321
|
-
import type { GtmContextValue, GtmConsentApi } from '@
|
|
322
|
-
import { useGtm, useGtmConsent } from '@
|
|
318
|
+
import type { GtmContextValue, GtmConsentApi } from '@jwiedeman/gtm-kit-solid';
|
|
319
|
+
import { useGtm, useGtmConsent } from '@jwiedeman/gtm-kit-solid';
|
|
323
320
|
|
|
324
321
|
function MyComponent() {
|
|
325
322
|
const gtm: GtmContextValue = useGtm();
|
|
@@ -335,7 +332,7 @@ function MyComponent() {
|
|
|
335
332
|
## Requirements
|
|
336
333
|
|
|
337
334
|
- SolidJS 1.0+
|
|
338
|
-
- `@
|
|
335
|
+
- `@jwiedeman/gtm-kit` (peer dependency)
|
|
339
336
|
|
|
340
337
|
---
|
|
341
338
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jwiedeman/gtm-kit-solid",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "SolidJS primitives and context for GTM Kit - Google Tag Manager integration.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"typecheck": "tsc --noEmit"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@jwiedeman/gtm-kit": "^1.1.
|
|
45
|
+
"@jwiedeman/gtm-kit": "^1.1.3"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"solid-js": "^1.0.0"
|