When Tolstoy runs on a Shopify store:
  • If Shopify’s Customer Privacy API is present, Tolstoy follows Shopify’s analytics consent state.
    • Analytics will be allowed when Shopify’s analytics state is anything other than ‘no’.
    • Analytics will be blocked when Shopify’s analytics state is ‘no’.
  • If Shopify’s API is not present, Tolstoy allows analytics by default unless you explicitly default to reject (see last section).
You can programmatically reject cookies when a user doenst accept analytics cooikes policy like this: Reject Policy:
window.tolstoyWidget?.postMessage({ eventName: 'tolstoy_reject_cookie_policy' });

Default Reject (No Cookies Until Accept)

If you want Tolstoy to start in a rejected state until the user explicitly accepts, set the following before loading the Tolstoy widget script:
localStorage.setItem('tolstoy-cookie-policy', 'rejected');
Then when a user accpets policy send this:
window.tolstoyWidget?.postMessage({ eventName: 'tolstoy_accept_cookie_policy' });