Solved

Disable clkn Wrapper

  • 1 December 2015
  • 34 replies
  • 1295 views

Is there a way to completely disable the clkn wrapper, so that my links are going direct to my goal. Thanks in advance for your help!

icon

Best answer by Anna_Z 19 July 2022, 00:05

View original

34 replies

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.

 

 

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>

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>

@ BrunaGarcia Thanks a lot! Your way is working! Greetings from Berlin.

Userlevel 3

Hey folks,

I’ve seen many people having issues trying to implement the script to remove Unbounce’s clkn/clkg wrapper from their pages. This could be related to Unbounce’s removal of our jQuery dependency, so to make it easier to troubleshoot if you encounter an issue, here it goes a few suggestions:

  • Make sure you are adding the jQuery CDN to your page. You can find how to do that here, as @dnlrose has mentioned on the comments.

  • In case you are using the script that starts with lp.jQuery(function... you might need to remove the lp. from your script since Unbounce won’t store jQuery in the lp variable anymore. In this case, you can go ahead and use the script like the one below:

     <script>
     $(function($) {
         $('a[href]').each(function(){
         $(this).attr('href',
         $(this).attr('href')
         .replace(/clk(n|g)\/https\//, 'https://')
         .replace(/clk(n|g)\/http\//, 'http://')
         .replace(/clk(n|g)\/tel\//, 'tel:'));
         });
       });
    </script>
    
    
  • You can also choose to remove the wrapper from an individual element on your page, using the script below:

        <script>
        (function(){
          // ID of button to remove Unbounce default tracking wrapper
          var btnId = $("#lp-pom-button-38");
          
          // Add URL to redirect the click
          var url = 'https://unsplash.com/wallpapers/cute/pug';
          
          // Change to true if you want to track the click as a goal
          var goal = false;
          
          btnId.attr('href', url);
          if (goal) {
            window.trackConversion = function() {
              $('body').append('<iframe src="clkg/http/unbouncepages.com/blankpage/" style="display: none"> </iframe>');
            };
            $(function($) {
              $(btnId).click(function () {
                trackConversion();
              });
            });
          }
        })();
        </script>

PS: Unfortunately, these scripts won’t work if you have the pass through URL parameters checked on Unbounce.

Hope that helps.

🙂

@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 there, I don’t know if the script is still working but we have everything blocked because this CLKN issue.

I have added the last script, but I receive this issue on Js Console:

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

Thanks! I got it working.

If the button has a tel instead of https you would need to update the script to search for that string instead.

Try this if you are using a tel link. You may need to make some changes to the replace function below, but this should get you started.

<script>
lp.jQuery(function() { $('a[href]').each(function() {
	$(this).attr('href', $(this).attr('href')
	.replace(/^\S*clk(n|g)\/https\//gi, 'https://')
	.replace(/^\S*clk(n|g)\/tel\//gi, 'tel:')
	.replace(/^\S*clk(n|g)\/http\//gi, 'http://'));
	});
});
</script>

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

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.

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

Thanks for this updated one! Extremely useful for a website caching issue we were having forwarding to /wp-content/ PDFs with /clkn/ parameters 🙂

@Raphael_Walker, This script worked excellently. The other script gave me quite a few issues, like you said. Thanks again.

There were some little issues with the script; here’s a fixed version. If it doesn’t work, open the console and fix any errors it gives.

<script>
lp.jQuery(function() { $('a[href]').each(function() {
	$(this).attr('href', $(this).attr('href')
	.replace(/^\S*clk(n|g)\/https\//gi, 'https://')
	.replace(/^\S*clk(n|g)\/http\//gi, 'http://'));
	});
});
</script>

Hi,

is there now another way to remove the tracking parameters?

The script does not work for me and I don’t know why. I placed it before the body end tag and tested both, soft and non-soft wrapping. I also insert the script on each landingpage and also tested it in the script manager for the whole domain. Nothing changed.

I just had to stop all my online marketing campaigns, so I would be really thankful for a fast solution.

Thanks,
Alex

Userlevel 7
Badge +3

Hi @Andy2,

Unfortunately, if you remove the wrappers from the links you will lose tracking through Unbounce.

However, I would still highly recommend using GA for any test check ups or post test analysis. The granularity of data you can get from GA is light years ahead of anything else.

To make it easier you can setup custom reports/dashboards or do a quick Google Data Studio report.

Best,
Hristian

Badge

@Hristian You’re right, I could track in GA (and do at times). My choice of words (" I cannot afford to lose tracking of conversions in Unbounce") perhaps too dramatic. But it also wouldn’t be NEARLY as easy as simply viewing results in Unbounce.

The loss of convenience would still be significant.

Userlevel 7
Badge +3

Hi @Andy2,

Just out of curiosity, if you are already using GTM/GA for tracking why can’t you afford to lose tracking of conversions in Unbounce.

GA can give you a lot more data to work with than the Unbounce reporting you get.

Best,
Hristian

Badge

Hi Jess, thanks very much for the response, but too bad no better solution yet! Please do let us know if something else becomes available.

Userlevel 7
Badge +1

Hey Andy,

The way that external links in Unbounce are formatted will essentially always have the clkn/clkg wrapping and unfortunately there is no way to remove them, as it’s built-in through the app back end.

You could add the links within the page using our Custom HTML tool, but that would require you to build the link as HTML with all of the styling of the text being done with HTML coding. You can read up on how to use that tool here: http://documentation.unbounce.com/hc/en-us/articles/203879070#content10.

Otherwise, I’m afraid there is no other way to have links in Unbounce without our link formatting.

I’ll be sure to update this post if another workaround comes across my desk!

Badge

Does anyone know if there are any new workarounds from Unbounce for this? I would like to implement cross domain tracking, but I cannot afford to lose tracking of conversions in Unbounce.

Got this script to work, Amazing.

Worked like a charm! Thanks so much, @sberman.

For anyone else’s reference, I placed this script before the closing body tag

Reply