Storing Data in Firestore DB and retrieving it

I am having a problem with duplicated data in the Firestore DB and my online store
This is how things are set up at them moment.

  1. The user enters items into the basket on the website and then views the basket.
  2. Basket details get passed from WebGTM to SSGTM using stape data server/client.
  3. SSGTM writes into firestore db with basket details adding sessionID as a reference point and writes a cookie so we can access the basket data on checkout as the basket isn’t available to webgtm on the purchase event.
  4. On purchase, webGTM sends order data to SSGTM and SSGTM retreives basket details from firestore DB in a variable using the sessionID from the webGTM.

The problem is that, if the basket is updated a new document with the same sessionID is created, rather than the original being updated in the Firebase

Does anyone have any ideas? - there may be a much better solution to this too! I am open to suggestions.

Thanks

Following this, I have now figured out that I can use the sessionID as the document name by adding it as a variable at the end of the firebase path.

All working like I imagined now.

1 Like