Version Description
Download this release
Release Info
Developer | joostdevalk |
Plugin | Google Analytics for WordPress by MonsterInsights |
Version | 2.9.2 |
Comparing to | |
See all releases |
Code changes from version 2.9.1 to 2.9.2
- googleanalytics.php +72 -47
- readme.txt +11 -4
googleanalytics.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Google Analytics for WordPress
|
|
4 |
Plugin URI: http://yoast.com/wordpress/analytics/
|
5 |
Description: This plugin makes it simple to add Google Analytics with extra search engines and automatic clickout and download tracking to your WordPress blog.
|
6 |
Author: Joost de Valk
|
7 |
-
Version: 2.9.
|
8 |
Author URI: http://yoast.com/
|
9 |
License: GPL
|
10 |
|
@@ -127,7 +127,7 @@ if ( ! class_exists( 'GA_Admin' ) ) {
|
|
127 |
}
|
128 |
}
|
129 |
|
130 |
-
foreach (array('extrase', 'imagese', 'trackoutbound', 'admintracking', 'trackadsense', 'userv2', 'allowanchor') as $option_name) {
|
131 |
if (isset($_POST[$option_name])) {
|
132 |
$options[$option_name] = true;
|
133 |
} else {
|
@@ -143,6 +143,15 @@ if ( ! class_exists( 'GA_Admin' ) ) {
|
|
143 |
echo "<div id=\"message\" class=\"updated\"><p>Google Analytics settings updated.</p></div>\n";
|
144 |
}
|
145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
$options = get_option('GoogleAnalyticsPP');
|
147 |
?>
|
148 |
<div class="wrap">
|
@@ -214,6 +223,14 @@ if ( ! class_exists( 'GA_Admin' ) ) {
|
|
214 |
<input type="checkbox" id="admintracking" name="admintracking" <?php if ($options['admintracking']) echo ' checked="checked" '; ?>/>
|
215 |
</td>
|
216 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
<tr class="advanced">
|
218 |
<th scope="row" valign="top">
|
219 |
<label for="dlextensions">Extensions of files to track as downloads</label><br/>
|
@@ -361,25 +378,12 @@ if ( ! class_exists( 'GA_Admin' ) ) {
|
|
361 |
$options['extrase'] = false;
|
362 |
$options['imagese'] = false;
|
363 |
$options['trackoutbound'] = true;
|
|
|
364 |
update_option('GoogleAnalyticsPP',$options);
|
365 |
}
|
366 |
|
367 |
-
function success() {
|
368 |
-
echo "
|
369 |
-
<div id='analytics-warning' class='updated'><p><strong>Congratulations! You have just activated Google Analytics.</p></div>
|
370 |
-
<style type='text/css'>
|
371 |
-
#adminmenu { margin-bottom: 7em; }
|
372 |
-
#analytics-warning { position: absolute; top: 7em; }
|
373 |
-
</style>";
|
374 |
-
} // end success()
|
375 |
-
|
376 |
function warning() {
|
377 |
-
echo "
|
378 |
-
<div id='analytics-warning' class='updated-ff0000'><p><strong>Google Analytics is not active.</strong> You must <a href='plugins.php?page=googleanalytics.php'>enter your UA String</a> for it to work.</p></div>
|
379 |
-
<style type='text/css'>
|
380 |
-
#adminmenu { margin-bottom: 6em; }
|
381 |
-
#analytics-warning { position: absolute; top: 7em; }
|
382 |
-
</style>";
|
383 |
} // end warning()
|
384 |
|
385 |
} // end class GA_Admin
|
@@ -408,33 +412,43 @@ if ( ! class_exists( 'GA_Filter' ) ) {
|
|
408 |
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
409 |
</script>
|
410 |
<script type="text/javascript">
|
411 |
-
|
|
|
|
|
412 |
</script>
|
413 |
<?php if ( $options["extrase"] == true ) {
|
414 |
echo("\t<script src=\"".$gapppluginpath."custom_se.js\" type=\"text/javascript\"></script>\n");
|
415 |
} ?>
|
416 |
<script type="text/javascript">
|
|
|
417 |
<?php if ( $options['userv2'] ) {
|
418 |
-
|
419 |
}
|
420 |
if ( $options['allowanchor'] ) {
|
421 |
-
|
422 |
}
|
|
|
|
|
|
|
|
|
|
|
423 |
if ( isset($options['domain']) && $options['domain'] != "" ) {
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
}
|
429 |
if (strpos($_SERVER['HTTP_REFERER'],"images.google") && strpos($_SERVER['HTTP_REFERER'],"&prev") && $options["imagese"]) { ?>
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
</script>
|
436 |
<!-- End of Google Analytics code -->
|
437 |
<?php
|
|
|
|
|
438 |
}
|
439 |
}
|
440 |
|
@@ -457,7 +471,6 @@ if (strpos($_SERVER['HTTP_REFERER'],"images.google") && strpos($_SERVER['HTTP_RE
|
|
457 |
* "host" e.g. store.boakes.org
|
458 |
*/
|
459 |
function ga_get_domain($uri){
|
460 |
-
|
461 |
$hostPattern = "/^(http:\/\/)?([^\/]+)/i";
|
462 |
$domainPattern = "/[^\.\/]+\.[^\.\/]+$/";
|
463 |
|
@@ -475,25 +488,34 @@ if (strpos($_SERVER['HTTP_REFERER'],"images.google") && strpos($_SERVER['HTTP_RE
|
|
475 |
|
476 |
$options = get_option('GoogleAnalyticsPP');
|
477 |
|
478 |
-
|
|
|
|
|
|
|
|
|
|
|
479 |
$coolBit = "";
|
480 |
$extension = substr($matches[3],-3);
|
481 |
$dlextensions = split(",",$options['dlextensions']);
|
482 |
-
if ( $target
|
483 |
-
if ($
|
484 |
-
$
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
|
|
|
|
|
|
|
|
497 |
}
|
498 |
return '<a ' . $matches[1] . 'href="' . $matches[2] . '//' . $matches[3] . '"' . ' ' . $matches[4] . '>' . $matches[5] . '</a>';
|
499 |
}
|
@@ -526,7 +548,10 @@ if (strpos($_SERVER['HTTP_REFERER'],"images.google") && strpos($_SERVER['HTTP_RE
|
|
526 |
|
527 |
function comment_author_link($text) {
|
528 |
$options = get_option('GoogleAnalyticsPP');
|
529 |
-
|
|
|
|
|
|
|
530 |
static $anchorPattern = '/(.*\s+.*?href\s*=\s*)["\'](.*?)["\'](.*)/';
|
531 |
preg_match($anchorPattern, $text, $matches);
|
532 |
if ($matches[2] == "") return $text;
|
4 |
Plugin URI: http://yoast.com/wordpress/analytics/
|
5 |
Description: This plugin makes it simple to add Google Analytics with extra search engines and automatic clickout and download tracking to your WordPress blog.
|
6 |
Author: Joost de Valk
|
7 |
+
Version: 2.9.2
|
8 |
Author URI: http://yoast.com/
|
9 |
License: GPL
|
10 |
|
127 |
}
|
128 |
}
|
129 |
|
130 |
+
foreach (array('extrase', 'imagese', 'trackoutbound', 'trackloggedin', 'admintracking', 'trackadsense', 'userv2', 'allowanchor') as $option_name) {
|
131 |
if (isset($_POST[$option_name])) {
|
132 |
$options[$option_name] = true;
|
133 |
} else {
|
143 |
echo "<div id=\"message\" class=\"updated\"><p>Google Analytics settings updated.</p></div>\n";
|
144 |
}
|
145 |
|
146 |
+
$templates = array();
|
147 |
+
$templates[] = "footer.php";
|
148 |
+
$file = file_get_contents(locate_template($templates));
|
149 |
+
// Check for wp_footer
|
150 |
+
preg_match('/.*(wp_footer\(\);).*/',$file,$matches);
|
151 |
+
if (!$matches[1]) {
|
152 |
+
echo "<div id=\"message\" class=\"error\"><p><strong>Warning</strong> wp_footer(); not found in your footer.php file, this might mean this plugin will not work!</p></div>\n";
|
153 |
+
}
|
154 |
+
|
155 |
$options = get_option('GoogleAnalyticsPP');
|
156 |
?>
|
157 |
<div class="wrap">
|
223 |
<input type="checkbox" id="admintracking" name="admintracking" <?php if ($options['admintracking']) echo ' checked="checked" '; ?>/>
|
224 |
</td>
|
225 |
</tr>
|
226 |
+
<tr class="advanced">
|
227 |
+
<th scope="row" valign="top">
|
228 |
+
<label for="trackloggedin">Segment logged in users</label><br/>
|
229 |
+
</th>
|
230 |
+
<td>
|
231 |
+
<input type="checkbox" id="trackloggedin" name="trackloggedin" <?php if ($options['trackloggedin']) echo ' checked="checked" '; ?>/>
|
232 |
+
</td>
|
233 |
+
</tr>
|
234 |
<tr class="advanced">
|
235 |
<th scope="row" valign="top">
|
236 |
<label for="dlextensions">Extensions of files to track as downloads</label><br/>
|
378 |
$options['extrase'] = false;
|
379 |
$options['imagese'] = false;
|
380 |
$options['trackoutbound'] = true;
|
381 |
+
$options['admintracking'] = true;
|
382 |
update_option('GoogleAnalyticsPP',$options);
|
383 |
}
|
384 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
385 |
function warning() {
|
386 |
+
echo "<div id='message' class='error'><p><strong>Google Analytics is not active.</strong> You must <a href='plugins.php?page=googleanalytics.php'>enter your UA String</a> for it to work.</p></div>";
|
|
|
|
|
|
|
|
|
|
|
387 |
} // end warning()
|
388 |
|
389 |
} // end class GA_Admin
|
412 |
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
413 |
</script>
|
414 |
<script type="text/javascript">
|
415 |
+
try {
|
416 |
+
var pageTracker = _gat._getTracker("<?php echo $options["uastring"]; ?>");
|
417 |
+
} catch(err) {}
|
418 |
</script>
|
419 |
<?php if ( $options["extrase"] == true ) {
|
420 |
echo("\t<script src=\"".$gapppluginpath."custom_se.js\" type=\"text/javascript\"></script>\n");
|
421 |
} ?>
|
422 |
<script type="text/javascript">
|
423 |
+
try {
|
424 |
<?php if ( $options['userv2'] ) {
|
425 |
+
echo("\t\t\tpageTracker._setLocalRemoteServerMode();\n");
|
426 |
}
|
427 |
if ( $options['allowanchor'] ) {
|
428 |
+
echo("\t\t\tpageTracker._setAllowAnchor(true);\n");
|
429 |
}
|
430 |
+
if ($options['trackloggedin'] && !isset($_COOKIE['__utmv']) && is_user_logged_in() ) {
|
431 |
+
echo("\t\t\tpageTracker._setVar('logged-in');\n");
|
432 |
+
} else {
|
433 |
+
echo("\t\t\t// Cookied already: ".$_COOKIE['__utmv']."\n");
|
434 |
+
}
|
435 |
if ( isset($options['domain']) && $options['domain'] != "" ) {
|
436 |
+
if (substr($options['domain'],0,1) != ".") {
|
437 |
+
$options['domain'] = ".".$options['domain'];
|
438 |
+
}
|
439 |
+
echo("\t\t\tpageTracker._setDomainName(\"".$options['domain']."\");\n");
|
440 |
}
|
441 |
if (strpos($_SERVER['HTTP_REFERER'],"images.google") && strpos($_SERVER['HTTP_REFERER'],"&prev") && $options["imagese"]) { ?>
|
442 |
+
regex = new RegExp("images.google.([^\/]+).*&prev=([^&]+)");
|
443 |
+
var match = regex.exec(pageTracker.qa);
|
444 |
+
pageTracker.qa = "http://images.google." + match[1] + unescape(match[2]); <?php }
|
445 |
+
?> pageTracker._trackPageview();
|
446 |
+
} catch(err) {}
|
447 |
</script>
|
448 |
<!-- End of Google Analytics code -->
|
449 |
<?php
|
450 |
+
} else if ((current_user_can('edit_users') && !$options["admintracking"])) {
|
451 |
+
echo "<!-- Google Analytics tracking code not shown because admin tracking is disabled -->";
|
452 |
}
|
453 |
}
|
454 |
|
471 |
* "host" e.g. store.boakes.org
|
472 |
*/
|
473 |
function ga_get_domain($uri){
|
|
|
474 |
$hostPattern = "/^(http:\/\/)?([^\/]+)/i";
|
475 |
$domainPattern = "/[^\.\/]+\.[^\.\/]+$/";
|
476 |
|
488 |
|
489 |
$options = get_option('GoogleAnalyticsPP');
|
490 |
|
491 |
+
// Break out immediately if the link is not an http or https link.
|
492 |
+
if (strpos($matches[2],"http") !== 0)
|
493 |
+
$target = false;
|
494 |
+
else
|
495 |
+
$target = GA_Filter::ga_get_domain($matches[3]);
|
496 |
+
|
497 |
$coolBit = "";
|
498 |
$extension = substr($matches[3],-3);
|
499 |
$dlextensions = split(",",$options['dlextensions']);
|
500 |
+
if ( $target ) {
|
501 |
+
if ( $target["domain"] != $origin["domain"] ){
|
502 |
+
if ($options['domainorurl'] == "domain") {
|
503 |
+
$coolBit .= "javascript:pageTracker._trackPageview('".$leaf."/".$target["host"]."');";
|
504 |
+
} else if ($options['domainorurl'] == "url") {
|
505 |
+
$coolBit .= "javascript:pageTracker._trackPageview('".$leaf."/".$matches[2]."//".$matches[3]."');";
|
506 |
+
}
|
507 |
+
} else if ( in_array($extension, $dlextensions) && $target["domain"] == $origin["domain"] ) {
|
508 |
+
$file = str_replace($origin["domain"],"",$matches[3]);
|
509 |
+
$file = str_replace('www.',"",$file);
|
510 |
+
$coolBit .= "javascript:pageTracker._trackPageview('".$options['dlprefix'].$file."');";
|
511 |
+
}
|
512 |
+
}
|
513 |
+
if ($coolBit != "") {
|
514 |
+
if (preg_match('/onclick=[\'\"](.*?)[\'\"]/i', $matches[4]) > 0) {
|
515 |
+
$matches[4] = preg_replace('/onclick=[\'\"](.*?)[\'\"]/i', 'onclick="' . $coolBit .' $1"', $matches[4]);
|
516 |
+
} else {
|
517 |
+
$matches[4] = 'onclick="' . $coolBit . '"' . $matches[4];
|
518 |
+
}
|
519 |
}
|
520 |
return '<a ' . $matches[1] . 'href="' . $matches[2] . '//' . $matches[3] . '"' . ' ' . $matches[4] . '>' . $matches[5] . '</a>';
|
521 |
}
|
548 |
|
549 |
function comment_author_link($text) {
|
550 |
$options = get_option('GoogleAnalyticsPP');
|
551 |
+
|
552 |
+
if (current_user_can('edit_users') && !$options["admintracking"]) {
|
553 |
+
return $text;
|
554 |
+
}
|
555 |
static $anchorPattern = '/(.*\s+.*?href\s*=\s*)["\'](.*?)["\'](.*)/';
|
556 |
preg_match($anchorPattern, $text, $matches);
|
557 |
if ($matches[2] == "") return $text;
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://yoast.com/donate/
|
|
4 |
Tags: analytics, google analytics, statistics
|
5 |
Requires at least: 2.2
|
6 |
Tested up to: 2.7.1
|
7 |
-
Stable tag: 2.9.
|
8 |
|
9 |
The Google Analytics for WordPress plugin automatically tracks and segments all outbound links from within posts, comment author links, links within comments, blogroll links and downloads. It also allows you to track AdSense clicks, add extra search engines, track image search queries and it will even work together with Urchin.
|
10 |
|
@@ -22,14 +22,21 @@ In the options panel for the plugin, you can determine the prefixes to use for t
|
|
22 |
|
23 |
This section describes how to install the plugin and get it working.
|
24 |
|
25 |
-
1. Delete any existing `
|
26 |
-
1. Upload `
|
27 |
1. Activate the plugin through the 'Plugins' menu in WordPress
|
28 |
1. Go to the options panel under the 'Plugins' menu and add your Analytics account number and set the settings you want.
|
29 |
|
30 |
== Changelog ==
|
31 |
|
32 |
-
1. 2.9.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
1. 2.9: Re arranged admin panel to have "standard" and "advanced" settigns, added domain tracking, added fix for double onclick parameter, as suggest here: http://wordpress.org/support/topic/241757
|
34 |
1. 2.8: Added the option to add setAllowAnchor to the tracking code, allowing you to track campaigns with # instead of ?
|
35 |
1. 2.7: Added option to select either header of footer position, added new AdSense integration options, remove now unneeded adsense tracking script.
|
4 |
Tags: analytics, google analytics, statistics
|
5 |
Requires at least: 2.2
|
6 |
Tested up to: 2.7.1
|
7 |
+
Stable tag: 2.9.2
|
8 |
|
9 |
The Google Analytics for WordPress plugin automatically tracks and segments all outbound links from within posts, comment author links, links within comments, blogroll links and downloads. It also allows you to track AdSense clicks, add extra search engines, track image search queries and it will even work together with Urchin.
|
10 |
|
22 |
|
23 |
This section describes how to install the plugin and get it working.
|
24 |
|
25 |
+
1. Delete any existing `gapp` folder from the `/wp-content/plugins/` directory
|
26 |
+
1. Upload `gapp` folder to the `/wp-content/plugins/` directory
|
27 |
1. Activate the plugin through the 'Plugins' menu in WordPress
|
28 |
1. Go to the options panel under the 'Plugins' menu and add your Analytics account number and set the settings you want.
|
29 |
|
30 |
== Changelog ==
|
31 |
|
32 |
+
1. 2.9.2:
|
33 |
+
* Added a check to see whether the wp_footer() call is in footer.php
|
34 |
+
* Added a message to the source when tracking code is left out because user is logged in as admin
|
35 |
+
* Added option to segment logged in users
|
36 |
+
* Added try - catch to script lines like in new Google Analytics scripts
|
37 |
+
* Fixed bug in warning when no UA code is entered
|
38 |
+
* Prevent link tracking when admin is logged in and admin tracking is disabled
|
39 |
+
* Now prevents parsing of non http and https link
|
40 |
1. 2.9: Re arranged admin panel to have "standard" and "advanced" settigns, added domain tracking, added fix for double onclick parameter, as suggest here: http://wordpress.org/support/topic/241757
|
41 |
1. 2.8: Added the option to add setAllowAnchor to the tracking code, allowing you to track campaigns with # instead of ?
|
42 |
1. 2.7: Added option to select either header of footer position, added new AdSense integration options, remove now unneeded adsense tracking script.
|