Hello,
I am getting duplicate page events when navigating on my wordpress website (doesn’t happen on page load). Interestingly these events seem to come from separate libraries
amplitude-ts-sdk-script/2.11.12
amplitude-ts-script/2.11.12
I am managing my own session_id, device_id and user_id internally, but I want to use Amplitude to help with tracking events.
Here is my code:
// Create and load the Amplitude script
var s = document.createElement("script");
s.src = "https://cdn.amplitude.com/script/API_KEY.js";
s.async = true;
s.onload = function() {
// Once the script is loaded, initialize Amplitude:
window.amplitude.init('API_KEY', {
fetchRemoteConfig: true,
autocapture: true,
sessionId: 'MY_INTERAL_SESSION_ID'
});
console.log("Amplitude loaded and initialized.");
};
document.head.appendChild(s);
On inital load, I get one page event. On subsequent refresh or navigation I get two page events.
When I split the code up and run in the console, 1) create and load the amplitue script → This triggers a new page
2) Initialise Amplitude → This sends a second page event. I would remove this but as I am tracking my own sessions, I need to add the session_id here.
How can I Implement using my own session and device id and only get one page event per page load.