Google Analytics by MonsterInsights
[Plugin: Google Analytics for WordPress] Problem with Javascript links (3 posts)

  1. jonathanpdx
    Posted 4 years ago #

    Problem: Google Analytics is breaking my Javascript-based hrefs in my anchor tags. I believe the problem is that it gets confused because I have a pair of single quotes (') inside a pair of double quotes (").

    The problem appears to be either in GA_Filter::ga_parse_link or the regular expression that is passed on line 1220 of googleanalytics.php:

    static $anchorPattern = '/<a (.*?)href=[\'\"](.*?)\/\/([^\'\"]+?)[\'\"](.*?)>(.*?)<\/a>/i';

    What ends up happening is that a URL that looks like this:

    <a href="javascript:launchWS('http://full_url_with_args');">here</a>

    will have the Google Analytics plugin turn it into the following:

    <a href="javascript:launchWS('http://full_url_with_args" );">here</a>

    Note how the closing single quote is turned into a double quote. Neither Chrome or Firefox interpret these as Javascript so the links fail to function.

    Any chance we can see a fix for this?


  2. jonathanpdx
    Posted 4 years ago #

    Please contact me if there's any assistance or more information I can provide.


  3. creyes123
    Posted 4 years ago #

    I ran into this problem, too. Disabling "Track outbound clicks & downloads" seems to get around it.

Topic Closed

This topic has been closed to new replies.

About this Plugin

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

About this Topic