Problem:
I want to track all the forwards to another page, e. g. when a user clicks on a link leading to the site https://example.com/ I want to track this event. The forward should also be tracked when calling:
location.href="https://example.com".
The code should look something like this:
$(window).on("forward???", function(event) {
//This is just some pseudo code
console.log(event.href);
});
Expected Output:
The program should output the link to which is forwarded to, e. g.:
https://example.com/page1
Is it possible to track such an event using jquery or vanilla javascript?
Purpose:
I'm looking for a solution to track all forwards to another page so I don't have to implement it for each link or location.href seperately.