简体   繁体   中英

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!

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'))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM