Question

Im new to this and im trying to rewrite URL so that utm_expid is hidden so if my url is:

http://www.myweb.com/?utm_expid=67183125-2

how would i make it so when user visits

myweb.com

it does not show utm_expid in url

Is this possible using PHP/JS?

NOTE: i cant use RUBY or any other languages except PHP/JS/HTML

Was it helpful?

Solution

There is a way. Just redirect the page to base url once the utm_expid=67183125-2 is got. ie,

if($_GET['utm_expid']) { //header to redirect to myweb.com }

Its a tricky way. Hope you are permitted to use it.

Just start a session and store value in session variable. you can regain it even page is re directed.

ie

<?php
session_start();
if($_GET['utm_expid']) {
$_SESSION['variable_name']=$_GET['utm_expid']
 //header to redirect to myweb.com 
}
?>

OTHER TIPS

Let me add this Javascript trick that is server agnostic.

if (location.search.indexOf('utm_expid') > -1) {
  history.replaceState('page', 'Title', '/')
}

I recommend you to place it at the end of the body.

If you wanted a clean URL (as you do for branding and manual sharing purposes), I'd script it so that you load a full page iFrame which loads the gA test queried URL. That way the user see s the clean URL in the address bar and still see the experiment.

You could use PHP to set up your index page (or any server side, or even client side script).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top