Skip to content

Commit

Permalink
Update shopify-ab-test.mdx
Browse files Browse the repository at this point in the history
update code for grabbing stableID
  • Loading branch information
cpreid authored Dec 26, 2024
1 parent baceda6 commit ffc14c1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions docs/guides/shopify-ab-test.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,16 @@ Below is boilerplate custom pixel code that provides a function to send events b
```js
/**
* Util function for tracking events back to statsig
* Find the user's stableID checking js-sdk >= v2 then fallback to v1 storage key
*/
const stableID = (function () {
for (var key in localStorage) {
if (key.includes('statsig.stable_id.')) return localStorage.getItem(key);
}
})() || localStorage.getItem('STATSIG_LOCAL_STORAGE_STABLE_ID');
const statsigEvent = async (eventKey, eventValue = null, metadata = {}, userObject = {}) => {
Object.assign(userObject, {
customIDs: {stableID: localStorage.getItem('STATSIG_LOCAL_STORAGE_STABLE_ID')} // attach stableID automatically
customIDs: {stableID: stableID} // attach stableID automatically
});
await fetch('https://events.statsigapi.net/v1/log_event', {
method: 'POST',
Expand Down Expand Up @@ -94,4 +100,4 @@ Whether you're using Shopify's [Hydrogen app](https://shopify.dev/docs/storefron
#### Integrating data sources for experiment metrics
Along with the measuring simple click stream and point-of-sale behavior as [outlined here](http://localhost:3004/guides/first-shopify-abtest#configure-event-tracking-and-metrics), commerce businesses performing deeper experimentation often want to integrate offline data systems and measure experiments using existing metrics that the broader business uses.
Commonly, the Data Warehouse is the source of truth for user purchase data and other categories of offline data. This affords customers the ability to define more [bespoke metrics](/statsig-warehouse-native/configuration/metrics#metric-types) using filtering, aggregations and incorporating other datasets in the warehouse for segmenting experiment results.
Commonly, the Data Warehouse is the source of truth for user purchase data and other categories of offline data. This affords customers the ability to define more [bespoke metrics](/statsig-warehouse-native/configuration/metrics#metric-types) using filtering, aggregations and incorporating other datasets in the warehouse for segmenting experiment results.

0 comments on commit ffc14c1

Please sign in to comment.