Event Deduplication Issue with History Change / Next.js

Hi Stape community,

I’ve been experimenting with the tool over the last few days and am planning to implement it. However, I’ve encountered one roadblock I can’t get around: event deduplication.

As explained in this video, Google Tag transports the event_id to the server: https://youtu.be/ytNnSVodsA4?si=HDcMz45lGYRfSULJ&t=1015

This works well in theory. However, our page is built with Next.js, and a click on the website to a different page triggers a page_view, but it’s just a History Change. This doesn’t renew the event_id transported to the server with the Page View trigger.

As a result, many page_view server-side events have the same event_id. Do you have any advice on how to resolve this issue?


Simply set on Google tag param send_page_view: false

And make a separate tag for page_view event that will trigger on DOM (or any other event you need on page load) + additional history change trigger.

This way you will control when page_view and its payload works. This is generally a best practice.

1 Like

Hi Alex,

Wow, that answer might just solve all the issues with my current setup! For some reason, I always receive two identical History Change events (page_view). Is that normal behavior? I assume this would also fire the trigger twice and lead to two page_views.

This most likely means that this is how your site works. Because GTM listens to browser events. You can see if your tags are triggering on both History Changes or just one.
You can also try using the History event (see what it is called in the data layer).