meetingingorkipark
meetingingorkipark

Reputation: 31

passing UTM parameters into a web-page content

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

Answers (1)

Jeremie
Jeremie

Reputation: 1018

You have several ways to do this:

  1. On the server side, if your server supports PHP, Python... or any server side language that can dynamically

In PHP you can retrieve the variable using the $_GET array.

$_GET['city']
  1. On the client side, using JavaScript

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

Related Questions