Skip to content

Commit

Permalink
Changed ga into __gaTracker
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Meerwaldt committed Oct 17, 2014
1 parent 256a8c5 commit bcd70a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions frontend/class-universal.php
Expand Up @@ -163,14 +163,14 @@ private function output_parse_link( $label, $matches ) {
switch ( $link['type'] ) {
case 'download':
if ( $this->options['track_download_as'] == 'pageview' ) {
$onclick = "ga('send', 'pageview', '" . esc_attr( $full_url ) . "');";
$onclick = "__gaTracker('send', 'pageview', '" . esc_attr( $full_url ) . "');";
} else {
$onclick = "ga('send', 'event', 'download', '" . esc_attr( $full_url ) . "');";
$onclick = "__gaTracker('send', 'event', 'download', '" . esc_attr( $full_url ) . "');";
}

break;
case 'email':
$onclick = "ga('send', 'event', 'mailto', '" . esc_attr( $link['original_url'] ) . "');";
$onclick = "__gaTracker('send', 'event', 'mailto', '" . esc_attr( $link['original_url'] ) . "');";

break;
case 'internal-as-outbound':
Expand All @@ -180,12 +180,12 @@ private function output_parse_link( $label, $matches ) {
$label = 'int';
}

$onclick = "ga('send', 'event', '" . esc_attr( $link['category'] ) . '-' . esc_attr( $label ) . "', '" . esc_attr( $full_url ) . "', '" . esc_attr( strip_tags( $link['link_text'] ) ) . "');";
$onclick = "__gaTracker('send', 'event', '" . esc_attr( $link['category'] ) . '-' . esc_attr( $label ) . "', '" . esc_attr( $full_url ) . "', '" . esc_attr( strip_tags( $link['link_text'] ) ) . "');";

break;
case 'outbound':
if ( $this->options['track_outbound'] == 1 ) {
$onclick = "ga('send', 'event', '" . esc_attr( $link['category'] ) . "', '" . esc_attr( $full_url ) . "', '" . esc_attr( strip_tags( $link['link_text'] ) ) . "');";
$onclick = "__gaTracker('send', 'event', '" . esc_attr( $link['category'] ) . "', '" . esc_attr( $full_url ) . "', '" . esc_attr( strip_tags( $link['link_text'] ) ) . "');";
}

break;
Expand Down
4 changes: 2 additions & 2 deletions frontend/views/tracking-universal.php
Expand Up @@ -3,14 +3,14 @@
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
})(window,document,'script','//www.google-analytics.com/analytics.js','__gaTracker');

<?php
// List the GA elements from the class-ga-js.php
if ( count( $gaq_push ) >= 1 ) {
foreach ( $gaq_push as $item ) {
if ( ! is_array( $item ) ) {
echo ' ga('.$item.");\n";
echo ' __gaTracker('.$item.");\n";
}
elseif ( isset( $item['value'] ) ) {
echo ' '.$item['value'] . "\n";
Expand Down

4 comments on commit bcd70a6

@adamgross42
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of using a non-standard function name?

@meganedesigns
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changing the function name ga() to __gaTracker() breaks event logging. What is the purpose of using __gaTracker() instead of the function Google recommends: ga()?

@philipjfulcher
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was it ever explained why this change was made? We had trouble with an third-party vendor's tracking scripts because of this.

@lkraav
Copy link

@lkraav lkraav commented on bcd70a6 Oct 2, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. This was just made, with no explanation.

Please sign in to comment.