@elevateab/sdk 1.4.8 → 1.4.9
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 +8 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,7 +21,8 @@ Hydrogen uses automatic analytics tracking via Shopify's `useAnalytics()` hook.
|
|
|
21
21
|
|
|
22
22
|
```tsx
|
|
23
23
|
// app/root.tsx
|
|
24
|
-
import { ElevateProvider
|
|
24
|
+
import { ElevateProvider } from "@elevateab/sdk";
|
|
25
|
+
import { ElevateHydrogenAnalytics } from "@elevateab/sdk/hydrogen";
|
|
25
26
|
import { Analytics } from "@shopify/hydrogen";
|
|
26
27
|
|
|
27
28
|
export default function Root() {
|
|
@@ -29,12 +30,14 @@ export default function Root() {
|
|
|
29
30
|
|
|
30
31
|
return (
|
|
31
32
|
<Analytics.Provider cart={data.cart} shop={data.shop} consent={data.consent}>
|
|
33
|
+
{/* ElevateProvider must be inside Analytics.Provider */}
|
|
32
34
|
<ElevateProvider
|
|
33
35
|
storeId="mystore.myshopify.com"
|
|
34
36
|
storefrontAccessToken={env.PUBLIC_STOREFRONT_API_TOKEN}
|
|
35
37
|
preventFlickering={true}
|
|
36
38
|
>
|
|
37
|
-
|
|
39
|
+
{/* ElevateHydrogenAnalytics must be inside ElevateProvider */}
|
|
40
|
+
<ElevateHydrogenAnalytics />
|
|
38
41
|
<Outlet />
|
|
39
42
|
</ElevateProvider>
|
|
40
43
|
</Analytics.Provider>
|
|
@@ -156,7 +159,9 @@ await trackSearchSubmitted({ searchQuery: "blue shirt" });
|
|
|
156
159
|
|
|
157
160
|
## Using A/B Tests
|
|
158
161
|
|
|
159
|
-
### useExperiment Hook
|
|
162
|
+
### useExperiment Hook (optional)
|
|
163
|
+
|
|
164
|
+
> **Note:** `useExperiment` is only needed if you want to write conditional logic in your components based on which variant a user is in. Most test types (content, custom code, split URL, price) run automatically — you don't need this hook for those.
|
|
160
165
|
|
|
161
166
|
```tsx
|
|
162
167
|
import { useExperiment } from "@elevateab/sdk";
|