Im running a self-hosted wordpress site and I am trying to tailor what secondary content a user sees based off of parameters in the utm code. All I was doing was <?php if (isset($_GET['utm_source'])) {dynamic_sidebar( 'sidebar-1' );}else {dynamic_sidebar( 'sidebar-2' );} ?>
For either testing for a UTM pram or a string variable to display one widget vs the other. After I did this and was testing I realized that the UTM code disappears after a user clicks to the next page or to any other page. i.e the utm query disappears from the end of the URL in the bar (but google is still tracking the session of course, just no visible utm). So after the initial landing page the condition is no longer true
I was wondering if anyone knows why it does this? Because I have been on sites where the UTM stays appended to the URL and when it disappears, like it does for me. Im assuming the tag is saved by wordpress in the database table, but can’t find an answer. I am trying to figure out what is going on. and if I should solve my problem by declaring a new variable to check or if I should tell wordpress to continue appending the UTM using a rewrite rule.
It is normal that UTM parameters (like any other parameters) are only used on the landing page.
Google Analytics requires them only on the landing page; these are session based values, so it is enough to see them on the first page call. Google Analytics will automatically attribute all subsequent pageviews in that session to the same visitor (identified by the client id which is stored in a cookie). You can see how this works exactly in the documentation. When the campaign parameter changes Google will start a new session.
Since attribution happens on the Google servers the GA code will do nothing to persist the utm parameters on the client side. It is quite normal that parameters from a link are not passed around though the site – if you want that you have to do some programming and add them yourself. Actually it would be better to set a cookie with the utm values, that way they would not be visible in the URL (which looks odd).
But it is normal that they show only in the incoming link. If you want the parameters to stay appended you have to append them yourself.