Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracker Storage (for realtime) #1043

Open
korgon opened this issue May 17, 2024 · 1 comment
Open

Tracker Storage (for realtime) #1043

korgon opened this issue May 17, 2024 · 1 comment
Assignees
Labels
type: feature New functionality

Comments

@korgon
Copy link
Contributor

korgon commented May 17, 2024

With the introduction of the Shopify Pixel Extension for tracking, management of the cookies and storage values for product views and cart contents are primarily handled by the extension. This is great because changes to the cart happen automatically as the cart is modified - currently though, we don't have a way of knowing when the extension is making those changes.

For recommendation realtime functionality to properly work with the Shopify Pixel we will need to leverage the fact that this extension also manages a localStorage entry ssCartProductsLocal (which we can rename if desired) that is kept up to date with the current cart contents. The idea is that instead of requiring cart attribution tracking in the integration, we could seamlessly connect with changes to ssCartProductsLocal. This will require a bit of a refactor to the snap-tracker, but would enable us to get realtime functionality much easier and more reliably.

This change also ties into our desire to move to having both cookies and storage for fallback for personalization data. This may mean that we could look into consolidating this data into a single storage entry instead of spanning multiple entries.

window.addEventListener('storage', function(event){
  // listen for changes to our storage entry
}, false);

https://developer.mozilla.org/en-US/docs/Web/API/Window/storage_event

@korgon korgon added the type: feature New functionality label May 17, 2024
@chrisFrazier77 chrisFrazier77 self-assigned this Aug 7, 2024
@chrisFrazier77
Copy link
Contributor

We were unable to use the suggested window.storage event due to the event only getting called if storage changes from another tab..

We then tried just manually triggering the storage event from the pixel, but ran into issues there as well because the "browser" api only gives access to the local storage and not the window.

SO now we have decided to just poll every 500ms for changes to local storage, only checking for a few seconds after each click on the document.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New functionality
Projects
None yet
Development

No branches or pull requests

2 participants