Support » Plugin: Google Analytics for WordPress by MonsterInsights » [Plugin: Google Analytics for WordPress] HowTo: Remove unwanted inserted space char from links

  • If outbound tracking is not used, the plugin still inserts an extra space at the end of link attributes (right after the “http://whatever”) like this:

    <a href="http://whatever" >Whatever</a>

    If you do not want that extra space char, locate this code in line 1187 of file googleanalytics.php, version 4.2.4:

    return '<a ' . $matches[1] . 'href="' . $matches[2] . '//' . $matches[3] . '"' . ' ' . $matches[4] . '>' . $matches[5] . '</a>';

    Replace with these two lines:

    $matches_4_fix = ($matches[4] != '') ? ' ' . $matches[4] : '';
    return '<a ' . $matches[1] . 'href="' . $matches[2] . '//' . $matches[3] . '"' . $matches_4_fix . '>' . $matches[5] . '</a>';

    Then your links will look like this in HTML source:

    <a href="http://whatever">Whatever</a>

    http://wordpress.org/extend/plugins/google-analytics-for-wordpress/

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Google Analytics for WordPress] HowTo: Remove unwanted inserted space char from links’ is closed to new replies.