Google Analytics by Yoast
OnClick Gets Broken by Outbound Link Tracking (2 posts)

  1. danbradster
    Posted 2 years ago #

    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/http://www.dpbolvw.net/']);this.innerHTML="Text has been changed';"

    Is there any way around this?


  2. Erik
    Posted 2 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Google Analytics by Yoast
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic