Product

Create, publish and optimize pages with a drag&drop, pixel perfect and mobile-friendly builder

Speed up the creation process with 400+ customizable templates for landing pages, pop-ups and sections

Track microconversions in your Dashboard and analyze events and clicks with visual map

Integrate your pages with your favorite mar-tech apps and solutions to get the flow of your campaign going

Drive sales and conversions with irresistible product displays and seamless shopping experiences

Use a reliable and secure platform that smoothly handles millions of visits

Solutions

How to generate more traffic and get more leads.

How to reach global audience with language versions of landing pages.

Resources

Master digital marketing with the help from savvy professionals and increase your website’s conversions

Guides for beginners, set-up instructions and creation tips to get started and optimize your pages

A free online course for landing page creators! Learn the secrets of high-converting pages and become an expert

Get the answers you’re looking for – contact us

Schedule a one-on-one meeting with us and learn more about the benefits of our platform

Hire a Design Expert or order an import of your existing page from other platforms to Landingi

Home Help Center Pass UTMs to another URL after button click

Pass UTMs to another URL after button click

TABLE OF CONTENT

UTM parameters can be passed from one URL address to another after clicking the button. This guide will walk you through configuring forwarding UTMs to the target URL, and with this solution, conversions will still be tracked in your landing page Dashboard.

You can set all landing page buttons or a selected button to pass UTMs.

TIP: Beforehand, learn more about UTM basics – check the guide on collecting UTMs and automatic form filling.

Pass UTMs through all buttons

Set a redirection

1. Go to the editor of your landing page.

2. For every button that is supposed to pass UTMs to another URL address:

  1. click the button,
  2. unfold the Click Action tab,
  3. select the Redirect action,
  4. enter the target URL (without parameters),
  5. select the Create a lead after a click option (Open in a new tab is optional).

3. Publish your landing page.

Add a JavaScript code

4. Navigate to your landing page Dashboard.

5. Go to the JavaScript Code tab and add a new script.

6. Copy the following code:

<script>
$(function(){
  const urlParams = new URLSearchParams(window.location.search);            
  $('.widget-button[subtype="redirect"]').each(function( index ) {
    let targetHref = new URL($(this).attr('href'), window.location.origin);    
    urlParams.forEach((value, key) => {
        targetHref.searchParams.append(key, value);
    });
    $(this).attr('href',  targetHref.toString());
  });
});
</script>

7. Name (1) the script and choose the Body bottom (2) position on the Main page (3). Paste the code in the content field (4).

Save by clicking Add script.

Go to your published landing page and check if the parameters are passed correctly.

Pass UTMs through a selected button

Set a redirection

1. Go to the editor of your landing page.

2. For the button that is supposed to pass UTMs to another URL address:

  1. click the button,
  2. unfold the Click Action tab,
  3. select the Redirect action,
  4. enter the target URL (without parameters),
  5. select the Create a lead after a click option (Open in a new tab is optional).

Get the button ID

3. Unfold the Other tab and copy the button ID number.

4. Publish your landing page.

Add a JavaScript code

5. Navigate to the landing page Dashboard.

6. Go to the JavaScript Code tab and add a new script.

7. Copy the following code:

<script>
$(function(){
  let buttonID = '#BUTTON_ID';
  let urlParams = new URLSearchParams(window.location.search);
  let targetHref = new URL($(buttonID).attr('href'), window.location.origin);    
  urlParams.forEach((value, key) => {
      targetHref.searchParams.append(key, value);
  });
  $(buttonID).attr('href',  targetHref.toString());
});
</script>

8. Change BUTTON_ID to the number copied from your button.

To add more buttons, duplicate the line of the code that starts with “let buttonID” and change BUTTON_ID to the ID of another button (remember to put # before its number).

9. Name (1) the script and choose the Body bottom (2) position on the Main page (3). Paste the code in the content field (4).

Save by clicking Add script.

Go to your published landing page and check if the parameters are passed correctly.

Read our blog post to learn more about UTMs, landing pages, and online campaigns.