Google Analytics for WordPress by MonsterInsights - Version 1.0

Version Description

Download this release

Release Info

Developer joostdevalk
Plugin Icon 128x128 Google Analytics for WordPress by MonsterInsights
Version 1.0
Comparing to
See all releases

Version 1.0

gapp/custom_se.js ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This JavaScript was developed by GA-Experts (http://www.ga-experts.co.uk) for Google Analytics
2
+ // Please use this code to overwrite the default set of Search Engines in the GA tracking code
3
+ // Use this code at your own risk. GA Experts takes no responsibility for errors, loss of data or any other complications arising from the use of this code
4
+ // Version 2.0 (Mar 2007) - many thanks to Brian Clifton and Tomas Remotigue for help with this
5
+ // For enquiries please contact mail@ga-experts.co.uk
6
+
7
+ // Dutch Search Engines added by Joost de Valk (http://www.joostdevalk.nl)
8
+ // For enquiries specifically about the Dutch SE's please contact joost@joostdevalk.nl
9
+
10
+ var _uOsr=new Array();
11
+ var _uOkw=new Array();
12
+
13
+ // Google EMEA Image domains
14
+ _uOsr[_uOsr.length]="images.google.co.uk"; _uOkw[_uOsr.length]="q";
15
+ _uOsr[_uOsr.length]="images.google.es"; _uOkw[_uOsr.length]="q";
16
+ _uOsr[_uOsr.length]="images.google.pt"; _uOkw[_uOsr.length]="q";
17
+ _uOsr[_uOsr.length]="images.google.it"; _uOkw[_uOsr.length]="q";
18
+ _uOsr[_uOsr.length]="images.google.fr"; _uOkw[_uOsr.length]="q";
19
+ _uOsr[_uOsr.length]="images.google.nl"; _uOkw[_uOsr.length]="q";
20
+ _uOsr[_uOsr.length]="images.google.be"; _uOkw[_uOsr.length]="q";
21
+ _uOsr[_uOsr.length]="images.google.de"; _uOkw[_uOsr.length]="q";
22
+ _uOsr[_uOsr.length]="images.google.no"; _uOkw[_uOsr.length]="q";
23
+ _uOsr[_uOsr.length]="images.google.se"; _uOkw[_uOsr.length]="q";
24
+ _uOsr[_uOsr.length]="images.google.dk"; _uOkw[_uOsr.length]="q";
25
+ _uOsr[_uOsr.length]="images.google.fi"; _uOkw[_uOsr.length]="q";
26
+ _uOsr[_uOsr.length]="images.google.ch"; _uOkw[_uOsr.length]="q";
27
+ _uOsr[_uOsr.length]="images.google.at"; _uOkw[_uOsr.length]="q";
28
+ _uOsr[_uOsr.length]="images.google.ie"; _uOkw[_uOsr.length]="q";
29
+ _uOsr[_uOsr.length]="images.google.ru"; _uOkw[_uOsr.length]="q";
30
+ _uOsr[_uOsr.length]="images.google.pl"; _uOkw[_uOsr.length]="q";
31
+
32
+ // Other Google Image search
33
+ _uOsr[_uOsr.length]="images.google.com"; _uOkw[_uOsr.length]="q";
34
+ _uOsr[_uOsr.length]="images.google.ca"; _uOkw[_uOsr.length]="q";
35
+ _uOsr[_uOsr.length]="images.google.com.au"; _uOkw[_uOsr.length]="q";
36
+ _uOsr[_uOsr.length]="images.google"; _uOkw[_uOsr.length]="q";
37
+
38
+ // Blogsearch
39
+ _uOsr[_uOsr.length]="blogsearch.google"; _uOkw[_uOsr.length]="q";
40
+
41
+ // Google EMEA Domains
42
+ _uOsr[_uOsr.length]="google.co.uk"; _uOkw[_uOsr.length]="q";
43
+ _uOsr[_uOsr.length]="google.es"; _uOkw[_uOsr.length]="q";
44
+ _uOsr[_uOsr.length]="google.pt"; _uOkw[_uOsr.length]="q";
45
+ _uOsr[_uOsr.length]="google.it"; _uOkw[_uOsr.length]="q";
46
+ _uOsr[_uOsr.length]="google.fr"; _uOkw[_uOsr.length]="q";
47
+ _uOsr[_uOsr.length]="google.nl"; _uOkw[_uOsr.length]="q";
48
+ _uOsr[_uOsr.length]="google.be"; _uOkw[_uOsr.length]="q";
49
+ _uOsr[_uOsr.length]="google.de"; _uOkw[_uOsr.length]="q";
50
+ _uOsr[_uOsr.length]="google.no"; _uOkw[_uOsr.length]="q";
51
+ _uOsr[_uOsr.length]="google.se"; _uOkw[_uOsr.length]="q";
52
+ _uOsr[_uOsr.length]="google.dk"; _uOkw[_uOsr.length]="q";
53
+ _uOsr[_uOsr.length]="google.fi"; _uOkw[_uOsr.length]="q";
54
+ _uOsr[_uOsr.length]="google.ch"; _uOkw[_uOsr.length]="q";
55
+ _uOsr[_uOsr.length]="google.at"; _uOkw[_uOsr.length]="q";
56
+ _uOsr[_uOsr.length]="google.ie"; _uOkw[_uOsr.length]="q";
57
+ _uOsr[_uOsr.length]="google.ru"; _uOkw[_uOsr.length]="q";
58
+ _uOsr[_uOsr.length]="google.pl"; _uOkw[_uOsr.length]="q";
59
+
60
+ // Yahoo EMEA Domains
61
+ _uOsr[_uOsr.length]="uk.yahoo.com"; _uOkw[_uOsr.length]="p";
62
+ _uOsr[_uOsr.length]="es.yahoo.com"; _uOkw[_uOsr.length]="p";
63
+ _uOsr[_uOsr.length]="pt.yahoo.com"; _uOkw[_uOsr.length]="p";
64
+ _uOsr[_uOsr.length]="it.yahoo.com"; _uOkw[_uOsr.length]="p";
65
+ _uOsr[_uOsr.length]="fr.yahoo.com"; _uOkw[_uOsr.length]="p";
66
+ _uOsr[_uOsr.length]="nl.yahoo.com"; _uOkw[_uOsr.length]="p";
67
+ _uOsr[_uOsr.length]="be.yahoo.com"; _uOkw[_uOsr.length]="p";
68
+ _uOsr[_uOsr.length]="de.yahoo.com"; _uOkw[_uOsr.length]="p";
69
+ _uOsr[_uOsr.length]="no.yahoo.com"; _uOkw[_uOsr.length]="p";
70
+ _uOsr[_uOsr.length]="se.yahoo.com"; _uOkw[_uOsr.length]="p";
71
+ _uOsr[_uOsr.length]="dk.yahoo.com"; _uOkw[_uOsr.length]="p";
72
+ _uOsr[_uOsr.length]="fi.yahoo.com"; _uOkw[_uOsr.length]="p";
73
+ _uOsr[_uOsr.length]="ch.yahoo.com"; _uOkw[_uOsr.length]="p";
74
+ _uOsr[_uOsr.length]="at.yahoo.com"; _uOkw[_uOsr.length]="p";
75
+ _uOsr[_uOsr.length]="ie.yahoo.com"; _uOkw[_uOsr.length]="p";
76
+ _uOsr[_uOsr.length]="ru.yahoo.com"; _uOkw[_uOsr.length]="p";
77
+ _uOsr[_uOsr.length]="pl.yahoo.com"; _uOkw[_uOsr.length]="p";
78
+
79
+ // UK specific
80
+ _uOsr[_uOsr.length]="hotbot.co.uk"; _uOkw[_uOsr.length]="query";
81
+ _uOsr[_uOsr.length]="excite.co.uk"; _uOkw[_uOsr.length]="q";
82
+ _uOsr[_uOsr.length]="bbc"; _uOkw[_uOsr.length]="q";
83
+ _uOsr[_uOsr.length]="tiscali"; _uOkw[_uOsr.length]="query";
84
+ _uOsr[_uOsr.length]="uk.ask.com"; _uOkw[_uOsr.length]="q";
85
+ _uOsr[_uOsr.length]="blueyonder"; _uOkw[_uOsr.length]="q";
86
+ _uOsr[_uOsr.length]="search.aol.co.uk"; _uOkw[_uOsr.length]="query";
87
+ _uOsr[_uOsr.length]="ntlworld"; _uOkw[_uOsr.length]="q";
88
+ _uOsr[_uOsr.length]="tesco.net"; _uOkw[_uOsr.length]="q";
89
+ _uOsr[_uOsr.length]="orange.co.uk"; _uOkw[_uOsr.length]="q";
90
+ _uOsr[_uOsr.length]="mywebsearch.com"; _uOkw[_uOsr.length]="searchfor";
91
+ _uOsr[_uOsr.length]="uk.myway.com"; _uOkw[_uOsr.length]="searchfor";
92
+ _uOsr[_uOsr.length]="searchy.co.uk"; _uOkw[_uOsr.length]="search_term";
93
+ _uOsr[_uOsr.length]="msn.co.uk"; _uOkw[_uOsr.length]="q";
94
+ _uOsr[_uOsr.length]="uk.altavista.com"; _uOkw[_uOsr.length]="q";
95
+ _uOsr[_uOsr.length]="lycos.co.uk"; _uOkw[_uOsr.length]="query";
96
+
97
+ // NL specific
98
+ _uOsr[_uOsr.length]="chello.nl"; _uOkw[_uOsr.length]="q1";
99
+ _uOsr[_uOsr.length]="home.nl"; _uOkw[_uOsr.length]="q";
100
+ _uOsr[_uOsr.length]="planet.nl"; _uOkw[_uOsr.length]="googleq=q";
101
+ _uOsr[_uOsr.length]="search.ilse.nl"; _uOkw[_uOsr.length]="search_for";
102
+ _uOsr[_uOsr.length]="search-dyn.tiscali.nl"; _uOkw[_uOsr.length]="key";
103
+ _uOsr[_uOsr.length]="startgoogle.startpagina.nl"; _uOkw[_uOsr.length]="q";
104
+ _uOsr[_uOsr.length]="vinden.nl"; _uOkw[_uOsr.length]="q";
105
+ _uOsr[_uOsr.length]="vindex.nl"; _uOkw[_uOsr.length]="search_for";
106
+ _uOsr[_uOsr.length]="zoeken.nl"; _uOkw[_uOsr.length]="query";
107
+ _uOsr[_uOsr.length]="zoeken.track.nl"; _uOkw[_uOsr.length]="qr";
108
+ _uOsr[_uOsr.length]="zoeknu.nl"; _uOkw[_uOsr.length]="Keywords";
109
+
110
+ // Extras
111
+ _uOsr[_uOsr.length]="alltheweb"; _uOkw[_uOsr.length]="q";
112
+ _uOsr[_uOsr.length]="ananzi"; _uOkw[_uOsr.length]="qt";
113
+ _uOsr[_uOsr.length]="anzwers"; _uOkw[_uOsr.length]="search";
114
+ _uOsr[_uOsr.length]="araby.com"; _uOkw[_uOsr.length]="q";
115
+ _uOsr[_uOsr.length]="dogpile"; _uOkw[_uOsr.length]="q";
116
+ _uOsr[_uOsr.length]="elmundo.es"; _uOkw[_uOsr.length]="q";
117
+ _uOsr[_uOsr.length]="ezilon.com"; _uOkw[_uOsr.length]="q";
118
+ _uOsr[_uOsr.length]="hotbot"; _uOkw[_uOsr.length]="query";
119
+ _uOsr[_uOsr.length]="indiatimes.com"; _uOkw[_uOsr.length]="query";
120
+ _uOsr[_uOsr.length]="iafrica.funnel.co.za"; _uOkw[_uOsr.length]="q";
121
+ _uOsr[_uOsr.length]="mywebsearch.com"; _uOkw[_uOsr.length]="searchfor";
122
+ _uOsr[_uOsr.length]="rambler.ru"; _uOkw[_uOsr.length]="words";
123
+ _uOsr[_uOsr.length]="search.aol.com"; _uOkw[_uOsr.length]="encquery";
124
+ _uOsr[_uOsr.length]="search.indiatimes.com"; _uOkw[_uOsr.length]="query";
125
+ _uOsr[_uOsr.length]="searcheurope.com"; _uOkw[_uOsr.length]="query";
126
+ _uOsr[_uOsr.length]="suche.web.de"; _uOkw[_uOsr.length]="su";
127
+ _uOsr[_uOsr.length]="terra.es"; _uOkw[_uOsr.length]="query";
128
+ _uOsr[_uOsr.length]="voila.fr"; _uOkw[_uOsr.length]="kw";
129
+
130
+ // Default GA (sorted)
131
+ _uOsr[_uOsr.length]="about"; _uOkw[_uOsr.length]="terms";
132
+ _uOsr[_uOsr.length]="alice"; _uOkw[_uOsr.length]="qs";
133
+ _uOsr[_uOsr.length]="alltheweb"; _uOkw[_uOsr.length]="q";
134
+ _uOsr[_uOsr.length]="altavista"; _uOkw[_uOsr.length]="q";
135
+ _uOsr[_uOsr.length]="aol"; _uOkw[_uOsr.length]="encquery";
136
+ _uOsr[_uOsr.length]="aol"; _uOkw[_uOsr.length]="query";
137
+ _uOsr[_uOsr.length]="ask"; _uOkw[_uOsr.length]="q";
138
+ _uOsr[_uOsr.length]="baidu"; _uOkw[_uOsr.length]="wd";
139
+ _uOsr[_uOsr.length]="cnn"; _uOkw[_uOsr.length]="query";
140
+ _uOsr[_uOsr.length]="gigablast"; _uOkw[_uOsr.length]="q";
141
+ _uOsr[_uOsr.length]="google"; _uOkw[_uOsr.length]="q";
142
+ _uOsr[_uOsr.length]="live.com"; _uOkw[_uOsr.length]="q";
143
+ _uOsr[_uOsr.length]="looksmart"; _uOkw[_uOsr.length]="qt";
144
+ _uOsr[_uOsr.length]="lycos"; _uOkw[_uOsr.length]="query";
145
+ _uOsr[_uOsr.length]="mamma"; _uOkw[_uOsr.length]="query";
146
+ _uOsr[_uOsr.length]="msn"; _uOkw[_uOsr.length]="q";
147
+ _uOsr[_uOsr.length]="najdi"; _uOkw[_uOsr.length]="q";
148
+ _uOsr[_uOsr.length]="netscape"; _uOkw[_uOsr.length]="s";
149
+ _uOsr[_uOsr.length]="search"; _uOkw[_uOsr.length]="q";
150
+ _uOsr[_uOsr.length]="seznam"; _uOkw[_uOsr.length]="w";
151
+ _uOsr[_uOsr.length]="virgilio.it"; _uOkw[_uOsr.length]="qs";
152
+ _uOsr[_uOsr.length]="voila.fr"; _uOkw[_uOsr.length]="kw";
153
+ _uOsr[_uOsr.length]="yahoo"; _uOkw[_uOsr.length]="p";
154
+ _uOsr[_uOsr.length]="yandex.ru"; _uOkw[_uOsr.length]="text";
gapp/googleanalytics.php ADDED
@@ -0,0 +1,445 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Google Analytics for WordPress
4
+ Plugin URI: http://www.joostdevalk.nl/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: 1.0
8
+ Author URI: http://www.joostdevalk.nl/
9
+ License: GPL
10
+
11
+ Based on Rich Boakes' Analytics plugin: http://boakes.org/analytics
12
+
13
+ */
14
+
15
+ $uastring = "UA-00000-0";
16
+
17
+ /*
18
+ * Admin User Interface
19
+ */
20
+
21
+ if ( ! class_exists( 'GA_Admin' ) ) {
22
+
23
+ class GA_Admin {
24
+
25
+ function add_config_page() {
26
+ global $wpdb;
27
+ if ( function_exists('add_submenu_page') ) {
28
+ add_submenu_page('plugins.php', 'Google Analytics for WordPress Configuration', 'Google Analytics', 1, basename(__FILE__), array('GA_Admin','config_page'));
29
+ }
30
+ } // end add_GA_config_page()
31
+
32
+ function config_page() {
33
+ global $dlextensions;
34
+ if ( isset($_POST['submit']) ) {
35
+ if (!current_user_can('manage_options')) die(__('You cannot edit the Google Analytics for WordPress options.'));
36
+ check_admin_referer('analyticspp-config');
37
+ $options['uastring'] = $_POST['uastring'];
38
+
39
+ if (isset($_POST['dlextensions']) && $_POST['dlextensions'] != "")
40
+ $options['dlextensions'] = strtolower($_POST['dlextensions']);
41
+ if (isset($_POST['dlprefix']) && $_POST['dlprefix'] != "")
42
+ $options['dlprefix'] = strtolower($_POST['dlprefix']);
43
+
44
+ if (isset($_POST['artprefix']) && $_POST['artprefix'] != "")
45
+ $options['artprefix'] = strtolower($_POST['artprefix']);
46
+ if (isset($_POST['comprefix']) && $_POST['comprefix'] != "")
47
+ $options['comprefix'] = strtolower($_POST['comprefix']);
48
+ if (isset($_POST['comautprefix']) && $_POST['comautprefix'] != "")
49
+ $options['comautprefix'] = strtolower($_POST['comautprefix']);
50
+ if (isset($_POST['blogrollprefix']) && $_POST['blogrollprefix'] != "")
51
+ $options['blogrollprefix'] = strtolower($_POST['blogrollprefix']);
52
+ if (isset($_POST['domainorurl']) && $_POST['domainorurl'] != "")
53
+ $options['domainorurl'] = $_POST['domainorurl'];
54
+
55
+ $options['position'] = $_POST['position'];
56
+
57
+ if (isset($_POST['extrase'])) {
58
+ $options['extrase'] = true;
59
+ } else {
60
+ $options['extrase'] = false;
61
+ }
62
+
63
+ if (isset($_POST['trackoutbound'])) {
64
+ $options['trackoutbound'] = true;
65
+ $options['position'] = 'header';
66
+ } else {
67
+ $options['trackoutbound'] = false;
68
+ }
69
+
70
+ if (isset($_POST['imagese'])) {
71
+ $options['imagese'] = true;
72
+ $options['extrase'] = true;
73
+ } else {
74
+ $options['imagese'] = false;
75
+ }
76
+
77
+ if (isset($_POST['userv2'])) {
78
+ $options['userv2'] = true;
79
+ } else {
80
+ $options['userv2'] = false;
81
+ }
82
+
83
+ $opt = serialize($options);
84
+ update_option('GoogleAnalyticsPP', $opt);
85
+ }
86
+ $mulch = ($uastring=""?"##-#####-#":$uastring);
87
+
88
+ $opt = get_option('GoogleAnalyticsPP');
89
+ $options = unserialize($opt);
90
+ ?>
91
+ <div class="wrap">
92
+ <script type="text/javascript">
93
+ function toggle_help(ele, ele2) {
94
+ var expl = document.getElementById(ele2);
95
+ if (expl.style.display == "block") {
96
+ expl.style.display = "none";
97
+ ele.innerHTML = "What's this?";
98
+ } else {
99
+ expl.style.display = "block";
100
+ ele.innerHTML = "Hide explanation";
101
+ }
102
+ }
103
+ </script>
104
+ <h2>Google Analytics for WordPress Configuration</h2>
105
+ <fieldset>
106
+ <form action="" method="post" id="analytics-conf" style="width: 35em; ">
107
+ <?php
108
+ if ( function_exists('wp_nonce_field') )
109
+ wp_nonce_field('analyticspp-config');
110
+ ?>
111
+ <p>
112
+ <strong><label for="uastring">Analytics User Account</label></strong>
113
+ <small><a href="#" onclick="javascript:toggle_help(this, 'expl');">What's this?</a></small><br/>
114
+ <input id="uastring" name="uastring" type="text" size="20" maxlength="40" value="<?php echo $options['uastring']; ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;" /><br/>
115
+ <div id="expl" style="display:none;">
116
+ <h3>Explanation</h3>
117
+ <p>Google Analytics is a statistics service provided
118
+ free of charge by Google. This plugin simplifies
119
+ the process of including the <em>basic</em> Google
120
+ Analytics code in your blog, so you don't have to
121
+ edit any PHP. If you don't have a Google Analytics
122
+ account yet, you can get one at
123
+ <a href="https://www.google.com/analytics/home/">analytics.google.com</a>.</p>
124
+
125
+ <p>In the Google interface, when you "Add Website
126
+ Profile" you are shown a piece of JavaScript that
127
+ you are told to insert into the page, in that script is a
128
+ unique string that identifies the website you
129
+ just defined, that is your User Account string
130
+ (it's shown in <strong>bold</strong> in the example below).</p>
131
+ <tt>&lt;script src="http://www.google-analytics.com/urchin.js" type="text/javascript"&gt;<br />&lt;/script&gt;<br />&lt;script type="text/javascript"&gt;<br />_uacct = "<strong><?php echo($mulch);?></strong>";<br />urchinTracker();<br />&lt;/script&gt;<br /></tt>
132
+
133
+ <p>Once you have entered your User Account String in
134
+ the box above your pages will be trackable by
135
+ Google Analytics.</p>
136
+ </div>
137
+ <?php if ($options['trackoutbound']) { ?>
138
+ <strong><label for="dlextensions">Extensions of files to track as downloads</label></strong><br/>
139
+ (If the extension is only two chars, prefix it with a dot, like '.js')
140
+ <input type="text" name="dlextensions" size="40" value="<?php echo $options['dlextensions']; ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;"/><br/>
141
+ <br/>
142
+ <strong><label for="dlprefix">Prefix for tracked downloads</label></strong><br/>
143
+ <input type="text" id="dlprefix" name="dlprefix" size="40" value="<?php echo $options['dlprefix']; ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;"/><br/>
144
+ <br/>
145
+ <strong><label for="artprefix">Prefix for outbound clicks from articles</label></strong><br/>
146
+ <input type="text" id="artprefix" name="artprefix" size="40" value="<?php echo $options['artprefix']; ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;"/><br/>
147
+ <br/>
148
+ <strong><label for="comprefix">Prefix for outbound clicks from within comments</label></strong><br/>
149
+ <input type="text" id="comprefix" name="comprefix" size="40" value="<?php echo $options['comprefix']; ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;"/><br/>
150
+ <br/>
151
+ <strong><label for="comautprefix">Prefix for outbound clicks from comment author links</label></strong><br/>
152
+ <input type="text" id="comautprefix" name="comautprefix" size="40" value="<?php echo $options['comautprefix']; ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;"/><br/>
153
+ <br/>
154
+ <strong><label for="blogrollprefix">Prefix for outbound clicks from blogroll links</label></strong><br/>
155
+ <input type="text" id="blogrollprefix" name="blogrollprefix" size="40" value="<?php echo $options['blogrollprefix']; ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;"/><br/>
156
+ <br/>
157
+ <strong><label for="domainorurl">Track full URL of outbound clicks or just the domain?</label></strong><br/>
158
+ <select name="domainorurl" id="domainorurl" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;">
159
+ <option value="domain"<?php if ($options['domainorurl'] == 'domain') { echo ' selected="selected"';} ?>>Just the domain</option>
160
+ <option value="url"<?php if ($options['domainorurl'] == 'url') { echo ' selected="selected"';} ?>>Track the complete URL</option>
161
+ </select><br/>
162
+ <br/>
163
+ <?php } else { ?>
164
+ <strong><label for="position">Place the script in the header or in the footer?</label></strong><br/>
165
+ <select name="position" id="position" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;">
166
+ <option value="header"<?php if ($options['position'] == 'header') { echo ' selected="selected"';} ?>>Header</option>
167
+ <option value="footer"<?php if ($options['position'] == 'footer') { echo ' selected="selected"';} ?>>Footer</option>
168
+ </select><br/>
169
+ <br/>
170
+ <?php } ?>
171
+ <input type="checkbox" id="trackoutbound" name="trackoutbound" <?php if ($options['trackoutbound']) echo ' checked="checked" '; ?>/>
172
+ <label for="trackoutbound">Track outbound clicks &amp; downloads</label><br/>
173
+ <br/>
174
+ <input type="checkbox" id="extrase" name="extrase" <?php if ($options['extrase']) echo ' checked="checked" '; ?>/>
175
+ <label for="extrase">Track extra Search Engines</label><br/>
176
+ <br/>
177
+ <input type="checkbox" id="imagese" name="imagese" <?php if ($options['imagese']) echo ' checked="checked" '; ?>/>
178
+ <label for="imagese">Track Google Image search keywords (this needs the tracking of extra search engines too)</label><br/>
179
+ <br/>
180
+ <input type="checkbox" id="userv2" name="userv2" <?php if ($options['userv2']) echo ' checked="checked" '; ?>/>
181
+ <label for="userv2">I use Urchin too, so add <code>_userv = 2;</code></label>
182
+ </p>
183
+ <p class="submit"><input type="submit" name="submit" value="Update Settings &raquo;" /></p>
184
+ </form>
185
+ </fieldset>
186
+ </div>
187
+ <?php
188
+ if (isset($options['uastring'])) {
189
+ if ($options['uastring'] == "") {
190
+ add_action('admin_footer', array('GA_Admin','warning'));
191
+ } else {
192
+ if (isset($_POST['submit'])) {
193
+ if ($_POST['uastring'] != $options['uastring'] ) {
194
+ add_action('admin_footer', array('GA_Admin','success'));
195
+ }
196
+ }
197
+ }
198
+ } else {
199
+ add_action('admin_footer', array('GA_Admin','warning'));
200
+ }
201
+
202
+ } // end config_page()
203
+
204
+ function restore_defaults() {
205
+ $options['dlextensions'] = 'doc,exe,.js,pdf,ppt,tgz,zip,xls';
206
+ $options['dlprefix'] = '/downloads';
207
+ $options['artprefix'] = '/outbound/article';
208
+ $options['comprefix'] = '/outbound/comment';
209
+ $options['comautprefix'] = '/outbound/commentauthor';
210
+ $options['blogrollprefix'] = '/outbound/blogroll';
211
+ $options['domainorurl'] = 'domain';
212
+ $options['position'] = 'header';
213
+ $options['userv2'] = false;
214
+ $options['extrase'] = false;
215
+ $options['imagese'] = false;
216
+ $options['trackoutbound'] = true;
217
+ $opt = serialize($options);
218
+ update_option('GoogleAnalyticsPP',$opt);
219
+ }
220
+
221
+ function success() {
222
+ echo "
223
+ <div id='analytics-warning' class='updated fade-ff0000'><p><strong>Congratulations! You have just activated Google Analytics - take a look at the source of your blog pages and search for the word 'urchin' to see how your pages have been affected.</p></div>
224
+ <style type='text/css'>
225
+ #adminmenu { margin-bottom: 7em; }
226
+ #analytics-warning { position: absolute; top: 7em; }
227
+ </style>";
228
+ } // end success()
229
+
230
+ function warning() {
231
+ echo "
232
+ <div id='analytics-warning' class='updated fade-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>
233
+ <style type='text/css'>
234
+ #adminmenu { margin-bottom: 6em; }
235
+ #analytics-warning { position: absolute; top: 7em; }
236
+ </style>";
237
+ } // end warning()
238
+
239
+ } // end class GA_Admin
240
+
241
+ } //endif
242
+
243
+
244
+ /**
245
+ * Code that actually inserts stuff into pages.
246
+ */
247
+ if ( ! class_exists( 'GA_Filter' ) ) {
248
+ class GA_Filter {
249
+
250
+ /*
251
+ * Insert the tracking code into the page
252
+ */
253
+ function spool_analytics() {
254
+ $opt = get_option('GoogleAnalyticsPP');
255
+ $options = unserialize($opt);
256
+
257
+ if ($options["uastring"] != "") {
258
+ echo("\n\t<!-- Google Analytics for WordPress | http://www.joostdevalk.nl/wordpress/google-analytics/ -->\n");
259
+ echo("\t<script src=\"http://www.google-analytics.com/urchin.js\" type=\"text/javascript\"></script>\n");
260
+ if ( $options["extrase"] == true ) {
261
+ echo("\t<script src=\"".get_bloginfo('url')."/wp-content/plugins/ga-extra-se/custom_se.js\" type=\"text/javascript\"></script>\n");
262
+ }
263
+ if ( $options['imagese'] ) {
264
+ echo("\t<script src=\"".get_bloginfo('url')."/wp-content/plugins/ga-extra-se/track-imagesearch.js\" type=\"text/javascript\"></script>\n");
265
+ }
266
+ echo("\t<script type=\"text/javascript\">\n");
267
+ echo("\t\t_uacct = \"".$options["uastring"]."\";\n");
268
+ if ( $options['userv2'] ) {
269
+ echo("\t\t_userv=2;\n");
270
+ }
271
+ echo("\t\turchinTracker();\n");
272
+ echo("\t</script>\n");
273
+ echo("\t<!-- End of Google Analytics code -->\n\n");
274
+ }
275
+ }
276
+
277
+ /* Create an array which contians:
278
+ * "domain" e.g. boakes.org
279
+ * "host" e.g. store.boakes.org
280
+ */
281
+ function ga_get_domain($uri){
282
+
283
+ $hostPattern = "/^(http:\/\/)?([^\/]+)/i";
284
+ $domainPattern = "/[^\.\/]+\.[^\.\/]+$/";
285
+
286
+ preg_match($hostPattern, $uri, $matches);
287
+ $host = $matches[2];
288
+ preg_match($domainPattern, $host, $matches);
289
+ return array("domain"=>$matches[0],"host"=>$host);
290
+
291
+ }
292
+
293
+ /* Take the result of parsing an HTML anchor ($matches)
294
+ * and from that, extract the target domain. If the
295
+ * target is not local, then when the anchor is re-written
296
+ * then an urchinTracker call is added.
297
+ *
298
+ * the format of the outbound link is definedin the $leaf
299
+ * variable which must begin with a / and which may
300
+ * contain multiple path levels:
301
+ * e.g. /outbound/x/y/z
302
+ * or which may be just "/"
303
+ *
304
+ */
305
+ function ga_parse_link($leaf, $matches){
306
+ global $origin ;
307
+
308
+ $opt = get_option('GoogleAnalyticsPP');
309
+ $options = unserialize($opt);
310
+
311
+ $target = GA_Filter::ga_get_domain($matches[3]);
312
+ $coolbit = "";
313
+ $extension = substr($matches[3],-3);
314
+ $dlextensions = split(",",$options['dlextensions']);
315
+ if ( $target["domain"] != $origin["domain"] ){
316
+ if ($options['domainorurl'] == "domain") {
317
+ $coolBit .= "onclick=\"javascript:urchinTracker('".$leaf."/".$target["host"]."');\"";
318
+ } else if ($options['domainorurl'] == "url") {
319
+ $coolBit .= "onclick=\"javascript:urchinTracker('".$leaf."/".$matches[2]."//".$matches[3]."');\"";
320
+ }
321
+ } else if ( in_array($extension, $dlextensions) && $target["domain"] == $origin["domain"] ) {
322
+ $file = str_replace($origin["domain"],"",$matches[3]);
323
+ $file = str_replace('www.',"",$file);
324
+ $coolBit .= "onclick=\"javascript:urchinTracker('".$options['dlprefix'].$file."');\"";
325
+ }
326
+ return '<a href="' . $matches[2] . '//' . $matches[3] . '"' . $matches[1] . $matches[4] . ' '.$coolBit.'>' . $matches[5] . '</a>';
327
+ }
328
+
329
+ function ga_parse_article_link($matches){
330
+ $opt = get_option('GoogleAnalyticsPP');
331
+ $options = unserialize($opt);
332
+ return GA_Filter::ga_parse_link($options['artprefix'],$matches);
333
+ }
334
+
335
+ function ga_parse_comment_link($matches){
336
+ $opt = get_option('GoogleAnalyticsPP');
337
+ $options = unserialize($opt);
338
+ return GA_Filter::ga_parse_link($options['comprefix'],$matches);
339
+ }
340
+
341
+ function the_content($text) {
342
+ static $anchorPattern = '/<a (.*?)href="(.*?)\/\/(.*?)"(.*?)>(.*?)<\/a>/i';
343
+ $text = preg_replace_callback($anchorPattern,array('GA_Filter','ga_parse_article_link'),$text);
344
+ return $text;
345
+ }
346
+
347
+ function comment_text($text) {
348
+ static $anchorPattern = '/<a (.*?)href="(.*?)\/\/(.*?)"(.*?)>(.*?)<\/a>/i';
349
+ $text = preg_replace_callback($anchorPattern,array('GA_Filter','ga_parse_comment_link'),$text);
350
+ return $text;
351
+ }
352
+
353
+ function comment_author_link($text) {
354
+ $opt = get_option('GoogleAnalyticsPP');
355
+ $options = unserialize($opt);
356
+
357
+ static $anchorPattern = '(.*href\s*=\s*)[\"\']*(.*)[\"\'] (.*)';
358
+ ereg($anchorPattern, $text, $matches);
359
+ if ($matches[2] == "") return $text;
360
+
361
+ $target = GA_Filter::ga_get_domain($matches[2]);
362
+ $coolbit = "";
363
+ $origin = GA_Filter::ga_get_domain($_SERVER["HTTP_HOST"]);
364
+ if ( $target["domain"] != $origin["domain"] ){
365
+ if ($options['domainorurl'] == "domain") {
366
+ $coolBit .= "onclick=\"javascript:urchinTracker('".$options['comautprefix']."/".$target["host"]."');\"";
367
+ } else if ($options['domainorurl'] == "url") {
368
+ $coolBit .= "onclick=\"javascript:urchinTracker('".$options['comautprefix']."/".$matches[2]."');\"";
369
+ }
370
+ }
371
+ return $matches[1] . "\"" . $matches[2] . "\" " . $coolBit ." ". $matches[3];
372
+ }
373
+
374
+ function bookmarks($bookmarks) {
375
+ $opt = get_option('GoogleAnalyticsPP');
376
+ $options = unserialize($opt);
377
+
378
+ foreach ( (array) $bookmarks as $bookmark ) {
379
+ if ($options['domainorurl'] == "domain") {
380
+ $target = GA_Filter::ga_get_domain($bookmark->link_url);
381
+ $bookmark->link_rel = $bookmark->link_rel."\" onclick=\"javascript:urchinTracker('".$options['blogrollprefix']."/".$target["host"]."');\"";
382
+ } else if ($options['domainorurl'] == "url") {
383
+ $bookmark->link_rel = $bookmark->link_rel."\" onclick=\"javascript:urchinTracker('".$options['blogrollprefix']."/".$bookmark->link_url."');\"";
384
+ }
385
+ }
386
+ return $bookmarks;
387
+ }
388
+ } // class GA_Filter
389
+ } // endif
390
+
391
+ $version = "0.61";
392
+ $uakey = "analytics";
393
+
394
+ if (function_exists("get_option")) {
395
+ if ($wp_uastring_takes_precedence) {
396
+ $opt = get_option('GoogleAnalyticsPP');
397
+ $options = unserialize($opt);
398
+ $uastring = $options['uastring'];
399
+ }
400
+ }
401
+
402
+ $mulch = ($uastring=""?"##-#####-#":$uastring);
403
+ $gaf = new GA_Filter();
404
+ $origin = $gaf->ga_get_domain($_SERVER["HTTP_HOST"]);
405
+
406
+ $opt = get_option('GoogleAnalyticsPP',"");
407
+
408
+ if ($opt == "") {
409
+ $options['dlextensions'] = 'doc,exe,.js,pdf,ppt,tgz,zip,xls';
410
+ $options['dlprefix'] = '/downloads';
411
+ $options['artprefix'] = '/outbound/article';
412
+ $options['comprefix'] = '/outbound/comment';
413
+ $options['comautprefix'] = '/outbound/commentauthor';
414
+ $options['blogrollprefix'] = '/outbound/blogroll';
415
+ $options['domainorurl'] = 'domain';
416
+ $options['position'] = 'header';
417
+ $options['userv2'] = false;
418
+ $options['extrase'] = false;
419
+ $options['imagese'] = false;
420
+ $options['trackoutbound'] = true;
421
+ $opt = serialize($options);
422
+ update_option('GoogleAnalyticsPP',$opt);
423
+ } else {
424
+ $options = unserialize($opt);
425
+ }
426
+
427
+ // adds the menu item to the admin interface
428
+ add_action('admin_menu', array('GA_Admin','add_config_page'));
429
+
430
+ // adds the footer so the javascript is loaded
431
+ if ($options['position'] =='footer') {
432
+ add_action('wp_footer', array('GA_Filter','spool_analytics'));
433
+ } else if ($options['position'] =='header') {
434
+ add_action('wp_head', array('GA_Filter','spool_analytics'));
435
+ }
436
+
437
+ if ($options['trackoutbound']) {
438
+ // filters alter the existing content
439
+ add_filter('the_content', array('GA_Filter','the_content'), 99);
440
+ add_filter('the_excerpt', array('GA_Filter','the_content'), 99);
441
+ add_filter('comment_text', array('GA_Filter','comment_text'), 99);
442
+ add_filter('get_bookmarks', array('GA_Filter','bookmarks'), 99);
443
+ add_filter('get_comment_author_link', array('GA_Filter','comment_author_link'), 99);
444
+ }
445
+ ?>
gapp/track-imagesearch.js ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function _uInfo(page) {
2
+ var p,s="",dm="",pg=_udl.pathname+_udl.search;
3
+ if (page && page!="") pg=_uES(page,1);
4
+ if (_ubd.referrer.search(/images.google/) != -1) {
5
+ var ref = _ubd.referrer;
6
+ var tldregex = new RegExp("images.google.([^\/]+)");
7
+ var tldmatch = tldregex.exec(ref);
8
+ var imgregex = new RegExp("&prev=([^&]+)");
9
+ var refmatch = imgregex.exec(ref);
10
+ refmatch = refmatch[1].replace(/%26/g,"&");
11
+ refmatch = refmatch.replace(/%3F/g,"?");
12
+ refmatch = refmatch.replace(/%3D/g,"=");
13
+ _ur = "http://www.images.google." + tldmatch[1] + refmatch;
14
+ } else {
15
+ _ur=_ubd.referrer;
16
+ }
17
+ if (!_ur || _ur=="") { _ur="-"; }
18
+ else {
19
+ dm=_ubd.domain;
20
+ if(_utcp && _utcp!="/") dm+=_utcp;
21
+ p=_ur.indexOf(dm);
22
+ if ((p>=0) && (p<=8)) { _ur="0"; }
23
+ if (_ur.indexOf("[")==0 && _ur.lastIndexOf("]")==(_ur.length-1)) { _ur="-"; }
24
+ }
25
+ s+="&utmn="+_uu;
26
+ if (_ufsc) s+=_uBInfo();
27
+ if (_uctm) s+=_uCInfo();
28
+ if (_utitle && _ubd.title && _ubd.title!="") s+="&utmdt="+_uES(_ubd.title);
29
+ if (_udl.hostname && _udl.hostname!="") s+="&utmhn="+_uES(_udl.hostname);
30
+ s+="&utmr="+_ur;
31
+ s+="&utmp="+pg;
32
+ if ((_userv==0 || _userv==2) && _uSP()) {
33
+ var i=new Image(1,1);
34
+ i.src=_ugifpath+"?"+"utmwv="+_uwv+s;
35
+ i.onload=function() {_uVoid();}
36
+ }
37
+ if ((_userv==1 || _userv==2) && _uSP()) {
38
+ var i2=new Image(1,1);
39
+ i2.src=_ugifpath2+"?"+"utmwv="+_uwv+s+"&utmac="+_uacct+"&utmcc="+_uGCS();
40
+ i2.onload=function() { _uVoid(); }
41
+ }
42
+ return;
43
+ }
readme.txt ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Google Analytics for WordPress ===
2
+ Contributors: joostdevalk
3
+ Donate link: http://www.joostdevalk.nl/donate/
4
+ Tags: analytics, google analytics, statistics
5
+ Requires at least: 2.2
6
+ Tested up to: 2.3
7
+ Stable tag: 1.0
8
+
9
+ The Google Analytics for WordPress plugina 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 add extra search engines, track image search queries and it will even work together with Urchin.
10
+
11
+ == Description ==
12
+
13
+ The Google Analytics for WordPress plugina 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 add extra search engines, track image search queries and it will even work together with Urchin.
14
+
15
+ In the options panel for the plugin, you can determine the prefixes to use for the different kinds of outbound links and downloads it tracks.
16
+
17
+ * [Google Analytics for WordPress](http://www.joostdevalk.nl/wordpress/google-analytics/).
18
+ * Other [Wordpress plugins](http://www.joostdevalk.nl/wordpress/) by the same author.
19
+
20
+ == Installation ==
21
+
22
+ This section describes how to install the plugin and get it working.
23
+
24
+ 1. Upload `gapp` folder to the `/wp-content/plugins/` directory
25
+ 1. Activate the plugin through the 'Plugins' menu in WordPress
26
+ 1. Go to the options panel under the 'Plugins' menu and add your Analytics account number and set the settings you want.
27
+
28
+ == Frequently Asked Questions ==
29
+
30
+ = This inflates my clicks, can I filter those out? =
31
+
32
+ Yes you can, create a new profile based on your original profile and name it something like 'domain - clean'. For each different outbound clicks or download prefix you have, create an exclude filter. You do this by:
33
+ 1. choosing a name for the filter, something like 'Exclude Downloads';
34
+ 1. selecting 'Custom filter' from the dropdown;
35
+ 1. selecting 'Exclude';
36
+ 1. selecting 'Request URI' in the Filter Field dropdown;
37
+ 1. setting the Filter Pattern to '/downloads/(.*)$' for a prefix '/downloads/';
38
+ 1. setting case sensitive to 'No'.
39
+
40
+ For some more info, see the screenshot under Screenshots.
41
+
42
+ = Can I run this plugin together with another Google Analytics plugin? =
43
+
44
+ No. You can not. It will break tracking.
45
+
46
+ = How do I check the image search stats and keywords after installing this plugin? =
47
+
48
+ Check out this <a href="http://www.joostdevalk.nl/wordpress/google-analytics/how-to-check-your-image-search-stats-and-keywords/">tutorial on checking your image search stats and keywords</a>.
49
+
50
+ = How do I check my outbound link and download stats? =
51
+
52
+ Check out this <a href="http://www.joostdevalk.nl/wordpress/google-analytics/checking-your-outbound-click-stats/">tutorial on checking your outbound click stats</a>.
53
+
54
+ = I want the image search keywords in one big overview... =
55
+
56
+ Create a <a href="http://www.joostdevalk.nl/wordpress/google-analytics/creating-a-google-analytics-filter-for-image-search/">Google Analytics filter for image search</a>.
57
+
58
+ == Screenshots ==
59
+
60
+ 1. Screenshot of the configuration panel for this plugin.
61
+ 2. Example of the exclude filter in Google Analytics.
62
+
63
+ == More info ==
64
+
65
+ * For more info, version history, etc. check out the page on my site about the [Google Analytics for WordPress plugin](http://www.joostdevalk.nl/wordpress/google-analytics/).
66
+ * To check out the other WordPress plugins I wrote, check out my [WordPress plugins](http://www.joostdevalk.nl/wordpress/) page.
67
+ * For updates about this plugin and other plugins I created read my [SEO blog](http://www.joostdevalk.nl/)
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file