Is it possible to use merge tags dynamic fields?

  1. Overview
  2. Frequently Asked Questions
  3. Is it possible to use merge tags dynamic fields?

It's possible to add dynamic fields within the builder.

Basically, you rewrite text on your landingpage with values from the URL.

 

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 the code-injection. The code-injection can be found in the bottom of 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>

Was this article helpful?