JournalTracking and ads

The event id: the small string that stops double counting

Send a purchase twice and Meta can count two sales. A shared event id is how the browser and the server agree it was one.

Two hands reaching toward their reflections in a round mirror.

Once a shop sends purchases from the browser and the server, one problem appears immediately. The same sale arrives twice. Without a rule, Meta counts it twice, and every number downstream is wrong.

The rule is an id

Every event you send carries an event id. The browser generates it when the order completes, and the server sends the same one. When Meta sees two events with the same name and the same id close together, it keeps one and drops the other.

What goes wrong

  • The browser and the server each make up their own id, so they never match.
  • The id changes on page refresh, so a customer who reloads the thank-you page creates a second sale.
  • The id is created on the server after the fact, so the browser has nothing to share.
  • Different events reuse one id, so a real purchase is dropped as a duplicate.

How we build it

The id is created once, at the moment the order is placed, and stored with the order. Both the browser event and the server event read it from there. A refresh reads the same stored value, so it cannot become a second sale.

How to test it

  1. Place a test order.
  2. Open Events Manager and look at the test events view.
  3. You should see the purchase arrive from both sources, then be marked as deduplicated.
  4. Refresh the confirmation page. The count should not move.

It is a small piece of plumbing, and it is the kind of thing a templated plugin often skips. We check it every time.

Photograph from Unsplash.

Bring us the account that is stuck.

Replies usually within 6 hours. Remote, working across UK, EU and US Eastern hours from UTC+1.