How to retrieve URL parameters (GET) from a customer code block

This is not a questions but something that I want to share in case that anybody has a similar need.

One example about how to get the parameters from the URL. For example:

<span id="name">name parameter</span><br>
<span id="phone">phone parameter</span><br>


var getUrlParameter = function getUrlParameter(sParam) {
    var sPageURL =,
        sURLVariables = sPageURL.split('&'),

    for (i = 0; i < sURLVariables.length; i++) {
        sParameterName = sURLVariables[i].split('=');

        if (sParameterName[0] === sParam) {
            return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
    return false;

var name = getUrlParameter('name');
var phone = getUrlParameter('phone');

console.log ("name:",name);
console.log ("phone:",phone);

document.getElementById("name").innerHTML = name;
document.getElementById("phone").innerHTML = phone;

1 Like

Thank you so much for taking the time to share this! Can I ask you something? How do you retrieve the result of fetching these parameters within our studio?

Hi @Jjenglert
I am using a Custom Block

And then just open the URL with the parameters name and phone in the URL.
For example:


1 Like

Oh, how wonderful! Thanks for teaching us something new :wink: