We have implemented a solution to ensure correct tracking and monitoring of abandoned carts and analytics data for stores currently on FastStorev1. Stores using this version of FastStore must update their project code with the new VTEX_METADATA
object.
This change only affects stores using FastStore v1.
What has changed?
Before, stores faced issues with tracking abandoned carts, as they were receiving a null
value. This resulted in an inability to track whether customers completed their purchases or not when they added items to their carts. As a result, sending cart reminders or notifications was a challenge.
Now, by implementing the VTEX_METADATA
object, you can set the correct account information, ensuring proper tracking of abandoned carts and analytics data for Return Customer (RC) and Activity Flow (AF) analytics trackers from VTEX.
What needs to be done?
Stores using FastStore v1 must define the VTEX_METADATA
object to ensure the correct behavior. To do so, open your FastStore project code and follow the steps below:
-
In the
src/sdk/analytics/index.tsx
file, add the highlighted code:_10if (typeof window !== 'undefined') {_10window.dataLayer = window.dataLayer ?? []_10window.VTEX_METADATA = {_10account: storeConfig.api.storeId,_10renderer: 'faststore',_10}_10} -
In the
src/typings/global.d.ts
file, add the highlighted code:_11declare module '*.scss';_11declare module '*.png';_11_11interface Window extends Window {_11dataLayer: any[];_11VTEX_METADATA: {_11account: string,_11renderer: "faststore"_11};_11sendrc: (eventName: string, eventValues?: any) => void_11} -
In the terminal, run
yarn dev
to sync the changes.
After syncing the changes, you can test the solution by checking the information in the following topics:
-
Check if
VTEX_METADATA
has been defined:- Access the provided localhost URL in your browser.
- Open the Dev Tools terminal, go to the Console tab, and check if the
window.VTEX_METADATA
is defined in the console, as illustrated in the image below.
-
Check if the data captured by Return Customer (RC) is updating the records in Master Data:
Refer to the topic Is the data captured by RC updating the records in Master Data?.