Support » Plugin: Google Analytics for WordPress by MonsterInsights » OnClick Gets Broken by Outbound Link Tracking

  • When outbound link tracking enabled, the onclick function in links gets broken and unusable within wordpress posts.

    For example, I write this –

    onclick="this.innerHTML='Text has been changed';"

    Then the plugin messes up the quotation marks, making the HTML wrong. Note the third quotation mark inserted in the middle, breaking the code.

    onclick="javascript:_gaq.push(['_trackPageview','/yoast-ga/outbound-article/']);this.innerHTML="Text has been changed';"

    Is there any way around this?

Viewing 1 replies (of 1 total)
  • I have noticed the same problem with links that (amazingly enough) contains single quotes ('). The same thing as danbradster has noticed happens in the link.

    For the link, the solution is to use urlencoding so that a single quote becomes “%27

    However for the onClick, I’d suggest calling a javascript function instead. e.g onclick="setTextFor(this.innerHTML)" – there can still be no single quotes in the method call so each message you’d want to set would have to have its own function.

    The incorrect handling of the single quote is, however, still a bug!

Viewing 1 replies (of 1 total)
  • The topic ‘OnClick Gets Broken by Outbound Link Tracking’ is closed to new replies.