Solved

Disable clkn Wrapper

  • 1 December 2015
  • 34 replies
  • 1312 views


Show first post

34 replies

this works thanks! I just realized unbounce was doing this, I dont understand why you want to sacrifice seo for usability (tracking stuff) in all honesty… If at all you were going to do that than at least mention it somewhere hehe.

Anyway thanks for this

If you don’t want to remove Unbounce’s conversion tracking, there is a solution if you use Google Tag Manager. See this article https://www.simoahava.com/analytics/decorate-links-decorate-forms-tags/. Apply the GA tag with the Decorate Link track type, then use a trigger that only applies to clicks on an unbounce page. You could use a trigger type of Link Clicks, then apply only to some links when the gtm.elementUrl matches regex ((.*)\/clkn\/http\/(.*))|((.*)\/clkn\/https\/(.*))|((.*)\/clkg\/https\/(.*))|((.*)\/clkg\/http\/(.*)). This will decorate all outbound links on Unbounce pages.

Hi,

Does this work for a button with a phone number wrapped in clkn? I added this script and it doesn’t seem to do it. Do I need to manipulate the script anyway or simply add it to the page?

Thanks

Thanks! I got it working.

I’m glad to hear that! Happy to help anytime

@dnlrose, make sure you have jquery enabled on your page. You can do that by following these instructions:

Look for part that reads " To enable jquery, you’ll need to click on the Javascripts*"

Once you enable jquery, save it and republish the page. Should work after that.

Hi everyone. If you need to replace the links without jQuery, here is the code:

<script>
  /*
   * Remove the "clckn/https/" part of the link added by Unbounce without using jQuery
   */
  const $allLinks = document.querySelectorAll("a[href]");
	
  window.onload = function () {
    for (let i = 0; i < $allLinks.length; i++) {
      const currentLink = $allLinks[i];
      console.log(currentLink.href)
      if (currentLink.href.includes("clkn/https")) {
        currentLink.href = currentLink.href.replace(window.location.href + "clkn/https", "https://");
        currentLink.href = currentLink.href.replace("clkn/https", "https://");
      }
    }
  }
</script>
Badge +1

Hi 👋

Here is a version of the script that works for Firefox as well (the original one with 3 lines works for Chrome and Safari only):


<script>  $(function($) {
    $('a[href]').each(function(){
      $(this).attr('href',
      $(this).attr('href')
 
    // these two lines make the script work for Firefox as well
      .replace(/.+?(?=(clk(n|g)\/https\/))/, '')
      .replace(/.+?(?=(clk(n|g)\/http\/))/, '')      
  
    // this works for Chrome and Safari only
      .replace(/clk(n|g)\/https\//, 'https://')
      .replace(/clk(n|g)\/http\//, 'http://')
      .replace(/clk(n|g)\/tel\//, 'tel:'));
    });
  });
</script>
Badge +1

Hi all,

The above version is outdated and will not work because jQuery is no longer stored in the lp variable. To disable the clkn/clkg wrappers on a page, follow these steps:

  1. Install jQuery as described here.
  2. Place the following script with the Before Body End Tag placement.
<script>
$(function($) {
$('a[href]').each(function(){
$(this).attr('href',
$(this).attr('href')

// these two lines make the script work for Firefox as well
.replace(/.+?(?=(clk(n|g)\/https\/))/, '')
.replace(/.+?(?=(clk(n|g)\/http\/))/, '')

// this works for Chrome and Safari only
.replace(/clk(n|g)\/https\//, 'https://')
.replace(/clk(n|g)\/http\//, 'http://')
.replace(/clk(n|g)\/tel\//, 'tel:')
.replace(/clk(n|g)\/rel\//, ''));
});
});
</script>

Warning: this script will disable all tracking on an Unbounce page.

 

 

Reply