Articles on: Frequently asked questions

Is it possible to use merge tags dynamic fields

It's possible to add dynamic fields within builder.
Basically, you rewrite text on your landingpage with values from the URL.

Take a look at the following example where we dynamically set Boston and the number 25 as amount of people, in this case:
https://n581imcuvo.campaign.direct/?city=Boston&people=25

Experiment around with the example above, change the city name in the URL and you'll see that the field changes on the page itself too. This might be very useful for dynamic and personalized ads.



To create this yourself, just write {city} and {people} as plain text on the page. Once the page is loaded, those words will get replaced with the values from the URL. This can be done with any URL.

EXAMPLES:



To accomplish this, you need to add the following code into code-injection. The lowest box in the sidebar. This feature will be built-in in the future, without the need of this code. But for now, it's a great workaround!

REQUIRED CODE:

<script type="text/javascript">
    function get_params() {
          var prmstr = window.location.search.substr(1);
          return prmstr != null && prmstr != "" ? transform_array(prmstr) : {};
    }
    function transform_array(prmstr) {
        var params = {};
        var prmarr = prmstr.split("&");
        for ( var i = 0; i < prmarr.length; i++) {
            var tmparr = prmarr[i].split("=");
            params[tmparr[0]] = tmparr[1];
        }
        return params;
    }
    var url_params = get_params();
    $(document).ready(function() {
        $('.ck').each(function(index) {
            var original_content = $(this).html();
            for (url_param in url_params) {
                text_var = '{'+url_param+'}';
                original_content = original_content.replace(text_var, decodeURIComponent(url_params[url_param].replaceAll('+', ' ')));
                $(this).html(original_content);
            }
        });
    });
</script>

Updated on: 29/03/2022

Was this article helpful?

Share your feedback

Cancel

Thank you!