I want to track the URL of the current page, then pass it to a URL variable to the next page.
For example
https://www.mywebsite.com
https://www.mywebsite.com/about/?fromsource=https://www.mywebsite.com
https://www.mywebsite.com/about/careers/?fromsource=https://www.mywebsite.com/about
https://www.mywebsite.com/contact/?fromsource=https://www.mywebsite.com/about/careers
So everytime someone moves to the next page, the URL of the previous page is add to a URL variable in the next page.
2
Answers
I’m not sure if this is the right way. I would use Google Analytics API referral data. But you can create the following shortcode:
If you want to add the code via PHP code:
If you want to use it in your editor you can add url’s as such:
The editor in the text mode, it will show up like this:
Why not use document.referrer?
So e.g. create a new variable in your web-analytics system and use the following js code to populate it:
In this case, you are not overwriting the actual URL, but instead create a new string which includes the requested parameter and can be used for any kind of tracking purpose.