Let us use the following example URL:

www.landingi.pl?name=Maciej&email=support@landingi.com

The GET parameters in the URL begin after a "?" mark, in this case, it will be name and email.

Suppose we want to create a mailing to our contact list and we want the email to contain links to our landing page. This is a good opportunity to personalize the message to mailing recipients, for example by adding the name of the addressee on the landing page.

In order to do this, you first need to paste the following code into the "Javascript" tab:

<script>
(function(){
    'use strict';
    var urlVars = getUrlVars();
    var findDynamicPhrases = new RegExp('\%(.*?)\%', 'g');
    var findPercent = new RegExp('%', 'g');
    var sections = $('.widget-text');
    function convertPhrase(string) {
        string = string.replace(findPercent, '').split('||');
        var dynamic = string[0];
        var fallback = string[1];
        var result = fallback;
        if ($.isEmptyObject(urlVars)) {
            return result;
        }
        $.each(urlVars, function (key, value) {
            if (value === '') {
                return false;
            }
            var findKey = new RegExp('{{'+key+'}}', 'g');
            if (dynamic.match(findKey)) {
                result = dynamic.replace(findKey, decodeURIComponent(value));
                return false;
            }
        });
        return result;
    }

    sections.html(function(i, old){
        return old.replace(findDynamicPhrases, convertPhrase);
    });
})();
</script>

Then you need to add the appropriate text, according to the following pattern:

% Hi {{name}}, || Hi!%

Of course, the content of the sentence can be changed, however - it is important that the whole sentence is between the "%" signs.

In the double bracket, we give the name of the parameter to be passed as dynamic content.

After two characters "|" place some alternative text if for some reason the search parameter GET will not be included in the link.

Did this answer your question?