Bookmarklet links broken by Google Analytics for WordPress (9 posts)

  1. SimonDorfman
    Posted 7 years ago #

    Is there a way to get the Google Analytics for WordPress plugin to ignore bookmarklet links? I'm working on a post and it's turning this link:

    <a href="javascript:void(window.open((location.href.replace(/\w+:\/\/[w{3}\.]*/,'https://authoring.')).replace(/(\/[^\/]+$)|\/$/,'/login.cfm'),''),'0');">LoginCommonSpot</a>

    Into this:
    <a href="javascript:void(window.open((location.href.replace(/\w+:\/\/[w{3}\.]*/,'https://authoring." onclick="javascript:pageTracker._trackPageview('/outbound/article/javascript:void(window.open((location.href.replace(/\w+:\/\/[w{3}\.]*/,'https://authoring.');")).replace(/(\/[^\/]+$)|\/$/,'/login.cfm'),''),'0');">LoginCommonSpot</a>

  2. SimonDorfman
    Posted 7 years ago #

    I was looking thru the plugin code and I think I know what needs to be changed.
    line 439
    static $anchorPattern = '/<a (.*?)href=[\'\"](.*?)\/\/([^\'\"]+?)[\'\"](.*?)>(.*?)<\/a>/i';

    Change this regex to exclude links that start with "javascript". Any regex experts wanna take a crack at that?

  3. SimonDorfman
    Posted 7 years ago #

    I posted to a regex specific forum asking for help with this here:

  4. SimonDorfman
    Posted 7 years ago #

    Thanks to Aussie Susan! She replied at the above mentioned regex forum with the answer to my problem.

    Here's the code that's working for me now:
    static $anchorPattern = '/<a (.*?)href=[\'\"](?!javascript)(.*?)\/\/([^\'\"]+?)[\'\"](.*?)>(.*?)<\/a>/i';

    I'm going to email the plugin author and suggest incorporating this change into the next release.

  5. zonk675
    Posted 7 years ago #

    Dang...I just noticed that my Bookmarkify's 'More' link wasn't working. Found out that it is Google Analytics causing the problem.
    I was stoked to find your thread...but I tried your code above and am not getting any results. My 'more' function is still 'broken'.


    Anyone else have any ideas?

    *Thx for posting your solution SimonDorfman :)

  6. Joost de Valk
    Posted 7 years ago #

    This should have been fixed in the 2.9 release, can anyone confirm? :)

  7. zonk675
    Posted 7 years ago #

    NOpe...I just updated and activated the plugin to test. It breaks my bookmarktify's 'more' link still.

  8. zonk675
    Posted 7 years ago #

    Any word on this Joost?
    Or, anyone found a workaround?

  9. Joost de Valk
    Posted 6 years ago #

    2.9.2 might fix it...

Topic Closed

This topic has been closed to new replies.

About this Topic