How to not have clkn ruin Google Analytics cross-domain tracking?

  • 23 September 2017
  • 5 replies
  • 86 views

For Google Analytics cross-domain tracking, a query parameter with the GA cookie needs to be added to every outbound link on the page that points to an external domain. The GTM & the AutoLink option, this is done automatically. The plugin basically looks for any links that point to a domain that isn’t yours & appends the GA cookie parameter to the URL.

BUT Unbounce clkn breaks that functionality, because it makes external links look like internal links. Therefore, the AutoLink plugin doesn’t recognize them as external links and doesn’t append the GA cookie parameter.

This is a BIG problem with one of our clients.

Does anyone know a workaround?


5 replies

Userlevel 7
Badge +4

Hi Ben,

Good question. I’ve heard of a few different approaches to this, although I have not tested them myself. You might want to check out this reply to a similar thread, where @sberman shared a script that might help. Although it is a bit old and as I mentioned, it’s not been tested personally.

Thanks Nicholas. This worked perfectly.

Userlevel 7
Badge +4

Awesome! Glad to hear that.

Hi Nicholas,

I am implemented this code on our page, but it’s not removing the clkn. Can you help me out?

This answer fails to mention several caveats. First off, disabling the wrappers this way may not work in all browsers  (try Firefox). Try the answer at the bottom of this thread instead:

Secondly, disabling the wrapper also disables all Unbounced tracking. I suppose this doesn’t matter if you’re tracking with GA4, but in my particular position it does matter. Marketing wants to track with both.

We need a solution that will decorate these links with the _gl parameter despite this issue. Unfortunately, I don’t know enough JavaScript to fix this, but I found some old code that used to work for a similar purpose. It no longer works. 

Any chance someone can update this to work with button clicks?

```
 

<script>

  $('.lp-pom-button, .lp-pom-text a, .lp-pom-image a').click(function(event) {

    var parentClass = $(this).parent().attr('class');

   

    var isFormRedirect =

      parentClass === 'lp-element lp-pom-box' &&

      window.module.lp.form.data.confirmAction === 'url' &&

      lp.jQuery('form').valid() === true;

 

    if (isFormRedirect) {

      ga(function(tracker) {

        var linker = new window.gaplugins.Linker(tracker);

        window.module.lp.form.data.confirmData = linker.decorate(window.module.lp.form.data.confirmData);

      });

    } else {

      ga('linker:decorate', this);

    }

  });

</script>

```

Reply