Reputation: 31
I am using a tracking software (Voluum) that generates for me campaign URLs with UTM parameters. Is there a way how I could pass the data from my UTM parameters and display it as a dynamic content on a web-page?
For example a visitor accesses domain.com/?city={city} where the {city} in his case is Berlin. is it possible to show him the word "Berlin" on the web-page right during his first visit?
thank you!
Upvotes: 1
Views: 625
Reputation: 1018
You have several ways to do this:
In PHP you can retrieve the variable using the $_GET array.
$_GET['city']
Here is a function that retrieves the variable 'name' from the URL
function getURLParameter(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
You can use it like that:
document.write(getURLParameter('city'))
Upvotes: 1