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

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>

Any progress on this? @sberman is absolutely right that this breaks Google Analytics cross-domain tracking.

Hi Adam, I’ve used a custom script to remove the clkn wrapper which solved the issue with GA tracking & conversions. However, you won’t be able to track Unbounce conversions. For us, this was not an issue since we simply set up conversions through GA.

(Remove the --s from the script below)

<–script–>
lp.jQuery(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–>

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>

Yes, one way to remove the clkn wrapper is using the custom HTML element. Unbounce does not apply tracking to links in that code base. I’m doing this now because I don’t want the click wrappers on links for SEO purposes.

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

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

Got this script to work, Amazing.

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 +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

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

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:

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.

🙂

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

Hi Andi,

Curious to know why you would need this ability. 🙂

Mark

Hi Mark,

the use of the Clkn wrapper could be a vulnerability issue for someone (such as a bank), since it may induce some hacker to make open redirect attack . It would be useful to be able to decide which links or buttons use the Clkn wrapper, with the possibility of excluding it if needed. It’s possible?
Thank you for your answer

Joe

Hi Folks! 
There isn’t any way to disable the  clkn wrapper at this time, as we use those clkn and clkg wrappers to keep track of stats for links and then use a 300-redirect once the appropriate count is fired back to Unbounce. Can you let us know if you’re running into any issues with these wrappers and reaching your goal? 

Thank you! This was just what I needed also for integration with CallRails to work.

Any update here on disabling the clkn wrapper?

Hi Justin, I know your post was from a year ago but I just wanted to mention that the clkn wrapper does disrupt cross-domain Google analytics tracking.

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.

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

@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.

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

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

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

Reply