Viewing 3 replies - 1 through 3 (of 3 total)
  • The apostrophe breaks the javascript-code, the name needs to be escaped or the apostrophe has to be removed.

    In file googleanalytics.php locate this line:

    $push[] = "'_setCustomVar',$customvarslot,'author','" . GA_Filter::ga_str_clean( get_the_author_meta( 'display_name', $wp_query->post->post_author ) ) . "',3";

    To escape the apostrophe with esc_js(), replace with e.g. this line:

    $push[] = "'_setCustomVar',$customvarslot,'author','" . esc_js( GA_Filter::ga_str_clean( get_the_author_meta( 'display_name', $wp_query->post->post_author ) ) ) . "',3";

    Not sure if the custom var for Google Analytics is allowed to contain an apostrophe, if it is not allowed, you could also use a str_replace() to remove the apostrophe like this:

    $push[] = "'_setCustomVar',$customvarslot,'author','" . str_replace( "'", "", GA_Filter::ga_str_clean( get_the_author_meta( 'display_name', $wp_query->post->post_author ) ) ) . "',3";

    I have the same issue, couldn’t find the code mentioned above in googleanalytics.php code

    Any idea if this worked?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Author name O'Mara breaks GA tags’ is closed to new replies.