I am currently sending tracking events in parallel - one path goes through Segment (which then forwards to Amplitude) and the other goes directly to Amplitude via their SDK. I am doing this for comparison purposes, as I will be deprecating one of these tracking methods soon.
However, I am encountering a significant data discrepancy in my Next.js (Pages router) application when tracking page views on a specific success URL (like /congratulations). Users are redirected to this page from an external headless payment gateway.
My current parallel setup looks like this:
Segment: Injected as a script in
_document.ts.Amplitude SDK directly: Using
@amplitude/analytics-browserinitialized in_app.tsxinside auseEffect.
Note: For both Segment and Amplitude, I am triggering the page view events manually rather than relying on auto-tracking.
The Problem: On this specific success page, the direct Amplitude SDK drops about 60-70% of the events compared to Segment. When looking into the device breakdown, the missing events are almost exclusively from the Samsung Phone device type (and occasionally from a few other devices). Amplitude registers exactly 0 events from Samsung phones, while Segment captures them perfectly.
Importantly, this problem does not occur anywhere else in the application - tracking on all other pages works perfectly fine and matches across both setups.
What I have investigated so far:
React Lifecycle/Unmount: I suspected users might be closing the tab/WebView immediately before the SDK could send the request. However, I added Datadog RUM custom logs, which confirmed that the React component mounts, and both
amplitude.init()and my manual page view track execute successfully. The code runs, but the network request never seems to reach Amplitude.Transport Method: I tried changing the Amplitude SDK config to use
transport: 'beacon'to prevent dropped requests on page unload, but it didn't change the outcome.Log Comparison: I compared event volumes across Segment➔Amplitude, Amplitude, and Datadog. Segment consistently manages to get through, while both Amplitude and Datadog log noticeably fewer events.
My Questions:
Has anyone else experienced this specific discrepancy with the
@amplitude/analytics-browserSDK onSamsung Phoneenvironments after a cross-site redirect?Why would Segment's script bypass whatever network filters or restrictions that are blocking the standard Amplitude SDK in this specific scenario?