Google Analytics - Version 1.5

Version Description

Download this release

Release Info

Developer webkinder
Plugin Icon 128x128 Google Analytics
Version 1.5
Comparing to
See all releases

Code changes from version 1.0 to 1.5

css/admin-styles.css CHANGED
@@ -3,10 +3,47 @@
3
  * Admin CSS Styles
4
  */
5
 
6
- #track-device button.wk-button.not-tracked {
7
- background-color: #c9ffc9;
8
- }
9
-
10
  #wk-google-analytics-settings>div {
11
  margin-bottom: 15px;
12
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  * Admin CSS Styles
4
  */
5
 
 
 
 
 
6
  #wk-google-analytics-settings>div {
7
  margin-bottom: 15px;
8
  }
9
+
10
+ #mc_embed_signup .mc-field-group {
11
+ margin-bottom: 15px;
12
+ }
13
+
14
+ /*====================GRID=================*/
15
+
16
+ @media screen and (min-width: 768px) {
17
+
18
+ .wk-left-part,
19
+ .wk-right-part {
20
+ display: inline-block;
21
+ }
22
+
23
+ .wk-left-part {
24
+ width: 70%;
25
+ vertical-align: top;
26
+ }
27
+
28
+ .wk-right-part {
29
+ width: 25%;
30
+ vertical-align:top;
31
+ }
32
+
33
+ }
34
+
35
+ /*==============MAILCHIMP==================*/
36
+
37
+ #mc_embed_signup .mc-field-group label {
38
+ width: 100px;
39
+ display: inline-block;
40
+ }
41
+
42
+ #mc_embed_signup .mc-field-group {
43
+ margin-bottom: 5px;
44
+ }
45
+
46
+ #mc_embed_signup .mc-field-group .asterisk {
47
+ margin-left: 5px;
48
+ color: red;
49
+ }
includes/mailchimp-form.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Google Analytics by WebKinder
4
+ * Mailchimp form for settings page
5
+ */
6
+ ?>
7
+ <!-- Begin MailChimp Signup Form -->
8
+ <div id="mc_embed_signup">
9
+ <form action="//webkinder.us12.list-manage.com/subscribe/post?u=979fe90d29c9ca9e25d5acc4b&amp;id=dfae840228" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
10
+ <div id="mc_embed_signup_scroll">
11
+ <h2><?php _e("Stay updated on this plugin", $this->textdomain); ?></h2>
12
+ <div class="mc-field-group">
13
+ <label for="mce-EMAIL"><?php _e("Email Address", $this->textdomain); ?><span class="asterisk">*</span></label>
14
+ <input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
15
+ </div>
16
+ <div class="mc-field-group">
17
+ <label for="mce-FNAME"><?php _e("First Name", $this->textdomain); ?><span class="asterisk">*</span></label>
18
+ <input type="text" value="" name="FNAME" class="required" id="mce-FNAME">
19
+ </div>
20
+ <div class="mc-field-group">
21
+ <label for="mce-LNAME"><?php _e("Last Name", $this->textdomain); ?><span class="asterisk">*</span></label>
22
+ <input type="text" value="" name="LNAME" class="required" id="mce-LNAME">
23
+ </div>
24
+
25
+ <div id="mce-responses" class="clear">
26
+ <div class="response" id="mce-error-response" style="display:none"></div>
27
+ <div class="response" id="mce-success-response" style="display:none"></div>
28
+ </div> <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
29
+ <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_979fe90d29c9ca9e25d5acc4b_dfae840228" tabindex="-1" value=""></div>
30
+ <div class="clear"><input type="submit" value="<?php _e("Subscribe", $this->textdomain); ?>" name="subscribe" id="mc-embedded-subscribe" class="button button-primary"></div>
31
+ </div>
32
+ </form>
33
+ </div>
34
+ <!--End mc_embed_signup-->
js/admin-functions.js CHANGED
@@ -8,23 +8,47 @@
8
  UntrackText: text_content.UntrackText,
9
  TrackText: text_content.TrackText,
10
 
11
- init: function( containerID ) {
 
 
12
  this.containerID = containerID;
13
- this.buttonSelector = containerID + " .wk-button";
14
- jQuery( containerID ).html('<button class="wk-button button-secondary"></button>');
 
15
 
16
- this.renderButton();
17
 
18
- jQuery( containerID + " .wk-button" ).click( function() {
19
  this.handleClick();
20
  }.bind(this) );
21
 
 
 
 
 
 
 
 
22
  },
23
 
24
- renderButton: function( containerID ) {
25
- var buttonText = Cookies.get( this.CookieName ) ? this.UntrackText : this.TrackText;
26
- var buttonClass = Cookies.get( this.CookieName ) ? "not-tracked" : "tracked";
27
- jQuery( this.buttonSelector ).removeClass('tracked not-tracked').addClass(buttonClass).text( buttonText );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  },
29
 
30
  handleClick: function() {
@@ -33,14 +57,13 @@
33
  } else {
34
  Cookies.set( this.CookieName , true, { expires: 365 } );
35
  }
36
- this.renderButton();
37
- console.log( document.cookie );
38
  }
39
 
40
  }
41
 
42
  jQuery(document).ready(function(){
43
 
44
- WKGA_AdminFunctions.init( '#track-device' );
45
 
46
- });
8
  UntrackText: text_content.UntrackText,
9
  TrackText: text_content.TrackText,
10
 
11
+ init: function( containerID, useTagManager ) {
12
+
13
+ //cookie handling
14
  this.containerID = containerID;
15
+ this.checkboxClass = 'wk-checkbox';
16
+ this.checkboxSelector = containerID + " ." + this.checkboxClass;
17
+ jQuery( containerID ).html('<label>'+this.TrackText+' </label><input type="checkbox" class="'+this.checkboxClass+'" />');
18
 
19
+ this.renderCheckbox();
20
 
21
+ jQuery( this.checkboxSelector ).change( function() {
22
  this.handleClick();
23
  }.bind(this) );
24
 
25
+ //analytics/tag manager switch
26
+ this.onlyUseOne( jQuery( useTagManager ).is(":checked") );
27
+
28
+ jQuery( useTagManager ).change( function() {
29
+ this.onlyUseOne( jQuery( useTagManager ).is(":checked") );
30
+ }.bind(this));
31
+
32
  },
33
 
34
+ onlyUseOne: function( useIt ) {
35
+ switch( useIt ) {
36
+ case true: {
37
+ jQuery('.use-google-tag-manager').children('input').prop('readonly', false);
38
+ jQuery('.use-google-analytics').children('input').prop('readonly', true);
39
+ break;
40
+ }
41
+ case false: {
42
+ jQuery('.use-google-analytics').children('input').prop('readonly', false);
43
+ jQuery('.use-google-tag-manager').children('input').prop('readonly', true);
44
+ break;
45
+ }
46
+ }
47
+ },
48
+
49
+ renderCheckbox: function( containerID ) {
50
+ var checkboxValue = Cookies.get( this.CookieName ) ? 1 : 0;
51
+ jQuery( this.checkboxSelector ).prop('checked', checkboxValue );
52
  },
53
 
54
  handleClick: function() {
57
  } else {
58
  Cookies.set( this.CookieName , true, { expires: 365 } );
59
  }
60
+ this.renderCheckbox();
 
61
  }
62
 
63
  }
64
 
65
  jQuery(document).ready(function(){
66
 
67
+ WKGA_AdminFunctions.init( '#track-device', '#use-google-tag-manager' );
68
 
69
+ });
lang/wk-ga-de_CH.mo CHANGED
Binary file
lang/wk-ga-de_CH.po CHANGED
@@ -1,51 +1,88 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: Google Analytics by WebKinder\n"
4
- "POT-Creation-Date: 2016-07-21 09:33+0200\n"
5
- "PO-Revision-Date: 2016-07-21 09:35+0200\n"
6
- "Last-Translator: \n"
7
- "Language-Team: \n"
8
- "Language: de\n"
9
- "MIME-Version: 1.0\n"
10
- "Content-Type: text/plain; charset=UTF-8\n"
11
- "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.8.8\n"
13
- "X-Poedit-Basepath: ..\n"
14
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
- "X-Poedit-SourceCharset: UTF-8\n"
16
- "X-Poedit-KeywordsList: __;_e\n"
17
- "X-Poedit-SearchPath-0: wk-ga.php\n"
18
-
19
- #: wk-ga.php:95
20
- msgid "Page visits from this device are not tracked."
21
- msgstr "Seitenbesuche von diesem Gerät werden nicht getrackt."
22
-
23
- #: wk-ga.php:96
24
- msgid "This device is treated like any other"
25
- msgstr "Dieses Gerät wird wie jedes Andere behandelt."
26
-
27
- #: wk-ga.php:154
28
- msgid "Test your tracking code now!"
29
- msgstr "Teste deinen Tracking Code jetzt!"
30
-
31
- #: wk-ga.php:158
32
- msgid ""
33
- "Enter your Google Analytics tracking code below. There are two additional "
34
- "mechanisms that allow you to stop tracking your own visits. The first one "
35
- "checks if you are logged in as a WordPress User. The second one allows you "
36
- "to stop tracking certain devices totally by setting a cookie."
37
- msgstr ""
38
- "Gib deinen Google Analytics Tracking Code unten ein. Es gibt zwei "
39
- "zusätzliche Mechanismen, die dir erlauben deine eigenen Seitenbesuche "
40
- "nicht mehr zu tracken. Der erste prüft, ob du als WordPress User "
41
- "angemeldet bist. Der zweite gibt dir die Möglichkeit über ein Cookie "
42
- "sämtliche Seitenbesuche von einem bestimmten Gerät aus nicht mehr zu "
43
- "tracken."
44
-
45
- #: wk-ga.php:166
46
- msgid "GA Tracking Code"
47
- msgstr "GA Tracking Code"
48
-
49
- #: wk-ga.php:170
50
- msgid "Track logged in users"
51
- msgstr "Eingeloggte Benutzer tracken"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Google Analytics by WebKinder\n"
4
+ "POT-Creation-Date: 2016-11-05 13:02+0100\n"
5
+ "PO-Revision-Date: 2016-11-05 13:02+0100\n"
6
+ "Last-Translator: \n"
7
+ "Language-Team: \n"
8
+ "Language: de\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.11\n"
13
+ "X-Poedit-Basepath: ..\n"
14
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
+ "X-Poedit-KeywordsList: __;_e\n"
17
+ "X-Poedit-SearchPath-0: wk-ga.php\n"
18
+
19
+ #: wk-ga.php:186
20
+ msgid "Do not track any visits from this device."
21
+ msgstr "Keine Besuche von diesem Gerät tracken."
22
+
23
+ #: wk-ga.php:215
24
+ msgid "Test your tracking code now!"
25
+ msgstr "Teste deinen Tracking Code jetzt!"
26
+
27
+ #: wk-ga.php:219
28
+ msgid ""
29
+ "Enter your Google Analytics tracking code below. You can also use Google Tag "
30
+ "Manager instead by checking the relevant setting."
31
+ msgstr ""
32
+ "Gib deinen Google Analytics Tracking Code unten ein. Alternativ kann auch "
33
+ "Google Tag Manager verwendet werden, indem das entsprechende Setting gesetzt "
34
+ "wird."
35
+
36
+ #: wk-ga.php:227
37
+ msgid "GA Tracking Code"
38
+ msgstr "GA Tracking Code"
39
+
40
+ #: wk-ga.php:231
41
+ msgid "Anonymize IP's"
42
+ msgstr "IP Anonymisierung"
43
+
44
+ #: wk-ga.php:235
45
+ msgid "Track logged in users"
46
+ msgstr "Eingeloggte Benutzer tracken"
47
+
48
+ #: wk-ga.php:239
49
+ msgid "Use Google Tag Manager instead"
50
+ msgstr "Google Tag Manager verwenden"
51
+
52
+ #: wk-ga.php:243
53
+ msgid "Google Tag Manager ID"
54
+ msgstr "Google Tag Manager ID"
55
+
56
+ #~ msgid "Page visits from this device are not tracked."
57
+ #~ msgstr "Seitenbesuche von diesem Gerät werden nicht getrackt."
58
+
59
+ #~ msgid "This device is treated like any other"
60
+ #~ msgstr "Dieses Gerät wird wie jedes Andere behandelt."
61
+
62
+ #~ msgid "Use Google tag manager instead"
63
+ #~ msgstr "Benutze Google Tag Manager"
64
+
65
+ #~ msgid "Stay updated on our plugins"
66
+ #~ msgstr "Erfahre das Neuste über unsere Plugins"
67
+
68
+ #~ msgid "Email Address"
69
+ #~ msgstr "Email Adresse"
70
+
71
+ #~ msgid "First Name"
72
+ #~ msgstr "Vorname"
73
+
74
+ #~ msgid "Last Name"
75
+ #~ msgstr "Nachname"
76
+
77
+ #~ msgid ""
78
+ #~ "Enter your Google Analytics tracking code below. There are two additional "
79
+ #~ "mechanisms that allow you to stop tracking your own visits. The first one "
80
+ #~ "checks if you are logged in as a WordPress User. The second one allows "
81
+ #~ "you to stop tracking certain devices totally by setting a cookie."
82
+ #~ msgstr ""
83
+ #~ "Gib deinen Google Analytics Tracking Code unten ein. Es gibt zwei "
84
+ #~ "zusätzliche Mechanismen, die dir erlauben deine eigenen Seitenbesuche "
85
+ #~ "nicht mehr zu tracken. Der erste prüft, ob du als WordPress User "
86
+ #~ "angemeldet bist. Der zweite gibt dir die Möglichkeit über ein Cookie "
87
+ #~ "sämtliche Seitenbesuche von einem bestimmten Gerät aus nicht mehr zu "
88
+ #~ "tracken."
lang/wk-ga-de_DE.mo CHANGED
Binary file
lang/wk-ga-de_DE.po CHANGED
@@ -1,51 +1,88 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: Google Analytics by WebKinder\n"
4
- "POT-Creation-Date: 2016-07-21 09:33+0200\n"
5
- "PO-Revision-Date: 2016-07-21 09:35+0200\n"
6
- "Last-Translator: \n"
7
- "Language-Team: \n"
8
- "Language: de\n"
9
- "MIME-Version: 1.0\n"
10
- "Content-Type: text/plain; charset=UTF-8\n"
11
- "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.8.8\n"
13
- "X-Poedit-Basepath: ..\n"
14
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
- "X-Poedit-SourceCharset: UTF-8\n"
16
- "X-Poedit-KeywordsList: __;_e\n"
17
- "X-Poedit-SearchPath-0: wk-ga.php\n"
18
-
19
- #: wk-ga.php:95
20
- msgid "Page visits from this device are not tracked."
21
- msgstr "Seitenbesuche von diesem Gerät werden nicht getrackt."
22
-
23
- #: wk-ga.php:96
24
- msgid "This device is treated like any other"
25
- msgstr "Dieses Gerät wird wie jedes Andere behandelt."
26
-
27
- #: wk-ga.php:154
28
- msgid "Test your tracking code now!"
29
- msgstr "Teste deinen Tracking Code jetzt!"
30
-
31
- #: wk-ga.php:158
32
- msgid ""
33
- "Enter your Google Analytics tracking code below. There are two additional "
34
- "mechanisms that allow you to stop tracking your own visits. The first one "
35
- "checks if you are logged in as a WordPress User. The second one allows you "
36
- "to stop tracking certain devices totally by setting a cookie."
37
- msgstr ""
38
- "Gib deinen Google Analytics Tracking Code unten ein. Es gibt zwei "
39
- "zusätzliche Mechanismen, die dir erlauben deine eigenen Seitenbesuche "
40
- "nicht mehr zu tracken. Der erste prüft, ob du als WordPress User "
41
- "angemeldet bist. Der zweite gibt dir die Möglichkeit über ein Cookie "
42
- "sämtliche Seitenbesuche von einem bestimmten Gerät aus nicht mehr zu "
43
- "tracken."
44
-
45
- #: wk-ga.php:166
46
- msgid "GA Tracking Code"
47
- msgstr "GA Tracking Code"
48
-
49
- #: wk-ga.php:170
50
- msgid "Track logged in users"
51
- msgstr "Eingeloggte Benutzer tracken"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Google Analytics by WebKinder\n"
4
+ "POT-Creation-Date: 2016-11-05 13:02+0100\n"
5
+ "PO-Revision-Date: 2016-11-05 13:02+0100\n"
6
+ "Last-Translator: \n"
7
+ "Language-Team: \n"
8
+ "Language: de\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.11\n"
13
+ "X-Poedit-Basepath: ..\n"
14
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
+ "X-Poedit-KeywordsList: __;_e\n"
17
+ "X-Poedit-SearchPath-0: wk-ga.php\n"
18
+
19
+ #: wk-ga.php:186
20
+ msgid "Do not track any visits from this device."
21
+ msgstr "Keine Besuche von diesem Gerät tracken."
22
+
23
+ #: wk-ga.php:215
24
+ msgid "Test your tracking code now!"
25
+ msgstr "Teste deinen Tracking Code jetzt!"
26
+
27
+ #: wk-ga.php:219
28
+ msgid ""
29
+ "Enter your Google Analytics tracking code below. You can also use Google Tag "
30
+ "Manager instead by checking the relevant setting."
31
+ msgstr ""
32
+ "Gib deinen Google Analytics Tracking Code unten ein. Alternativ kann auch "
33
+ "Google Tag Manager verwendet werden, indem das entsprechende Setting gesetzt "
34
+ "wird."
35
+
36
+ #: wk-ga.php:227
37
+ msgid "GA Tracking Code"
38
+ msgstr "GA Tracking Code"
39
+
40
+ #: wk-ga.php:231
41
+ msgid "Anonymize IP's"
42
+ msgstr "IP Anonymisierung"
43
+
44
+ #: wk-ga.php:235
45
+ msgid "Track logged in users"
46
+ msgstr "Eingeloggte Benutzer tracken"
47
+
48
+ #: wk-ga.php:239
49
+ msgid "Use Google Tag Manager instead"
50
+ msgstr "Google Tag Manager verwenden"
51
+
52
+ #: wk-ga.php:243
53
+ msgid "Google Tag Manager ID"
54
+ msgstr "Google Tag Manager ID"
55
+
56
+ #~ msgid "Page visits from this device are not tracked."
57
+ #~ msgstr "Seitenbesuche von diesem Gerät werden nicht getrackt."
58
+
59
+ #~ msgid "This device is treated like any other"
60
+ #~ msgstr "Dieses Gerät wird wie jedes Andere behandelt."
61
+
62
+ #~ msgid "Use Google tag manager instead"
63
+ #~ msgstr "Benutze Google Tag Manager"
64
+
65
+ #~ msgid "Stay updated on our plugins"
66
+ #~ msgstr "Erfahre das Neuste über unsere Plugins"
67
+
68
+ #~ msgid "Email Address"
69
+ #~ msgstr "Email Adresse"
70
+
71
+ #~ msgid "First Name"
72
+ #~ msgstr "Vorname"
73
+
74
+ #~ msgid "Last Name"
75
+ #~ msgstr "Nachname"
76
+
77
+ #~ msgid ""
78
+ #~ "Enter your Google Analytics tracking code below. There are two additional "
79
+ #~ "mechanisms that allow you to stop tracking your own visits. The first one "
80
+ #~ "checks if you are logged in as a WordPress User. The second one allows "
81
+ #~ "you to stop tracking certain devices totally by setting a cookie."
82
+ #~ msgstr ""
83
+ #~ "Gib deinen Google Analytics Tracking Code unten ein. Es gibt zwei "
84
+ #~ "zusätzliche Mechanismen, die dir erlauben deine eigenen Seitenbesuche "
85
+ #~ "nicht mehr zu tracken. Der erste prüft, ob du als WordPress User "
86
+ #~ "angemeldet bist. Der zweite gibt dir die Möglichkeit über ein Cookie "
87
+ #~ "sämtliche Seitenbesuche von einem bestimmten Gerät aus nicht mehr zu "
88
+ #~ "tracken."
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Google Analytics ===
2
  Contributors: webkinder
3
- Tags: google analytics, tracking code
4
  Requires at least: 3.0
5
  Tested up to: 4.6
6
- Stable tag: 1.0
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -11,7 +11,14 @@ Google Analytics for WordPress without tracking your own visits.
11
 
12
  == Description ==
13
 
14
- Enable Google Analytics on all pages without tracking your own visits. You can exclude any logged in user as well as ignore a device completely by setting a cookie.
 
 
 
 
 
 
 
15
 
16
  If you have any questions or feature requests, feel free to contact us via support@webkinder.ch.
17
 
@@ -24,9 +31,19 @@ If you have any questions or feature requests, feel free to contact us via suppo
24
 
25
  == Screenshots ==
26
 
27
- 1.The Settings Page of this Plugin. The cookie mechanism is activated here.
28
 
29
  == Changelog ==
30
 
31
  = 1.0 =
32
- * Initial release
 
 
 
 
 
 
 
 
 
 
1
  === Google Analytics ===
2
  Contributors: webkinder
3
+ Tags: google analytics, tracking code, analytics, anonymization, anonymize, anonymizeIp, cookie, Datenschutz, ga, gaoptout, google, googleanalytics, google tag manager, gtm, Datenschutz, datenschutzkonform, script, snippet
4
  Requires at least: 3.0
5
  Tested up to: 4.6
6
+ Stable tag: 1.5
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
11
 
12
  == Description ==
13
 
14
+
15
+ Enable Google Analytics on all pages without tracking your own visits. You can exclude any logged in user as well as ignore a device completely by setting a cookie.
16
+
17
+
18
+
19
+ New feature: You can now also use Google Tag Manager with this plugin.
20
+
21
+ We would love to hear your feedback in a [review](https://wordpress.org/support/plugin/wk-google-analytics/reviews/). It helps us improve and expand the plugin according to your needs.
22
 
23
  If you have any questions or feature requests, feel free to contact us via support@webkinder.ch.
24
 
31
 
32
  == Screenshots ==
33
 
34
+ 1. The settings page of this plugin. The cookie mechanism is activated here.
35
 
36
  == Changelog ==
37
 
38
  = 1.0 =
39
+ * Initial release
40
+
41
+ = 1.1 =
42
+ * added anonymize IP's option
43
+ * added uninstall file
44
+
45
+ = 1.2 =
46
+ * added support for Google Tag Manager
47
+
48
+ = 1.5 =
49
+ * Visual improvement of the settings page
uninstall.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // If uninstall is not called from WordPress, exit
3
+ if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
4
+ exit();
5
+ }
6
+
7
+ delete_option( 'ga_tracking_code' );
8
+ delete_option( 'track_logged_in' );
9
+ delete_option( 'ga_anonymize_ip' );
10
+ delete_option( 'ga_use_tag_manager' );
11
+ delete_option('ga_tag_manager_id');
12
+
13
+ // For site options in Multisite
14
+ delete_site_option( 'ga_tracking_code' );
15
+ delete_site_option( 'track_logged_in' );
16
+ delete_site_option( 'ga_anonymize_ip' );
17
+ delete_site_option( 'ga_use_tag_manager' );
18
+ delete_site_option('ga_tag_manager_id');
19
+ ?>
wk-ga.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Google Analytics by WebKinder
4
  Plugin URI: https://wordpress.org/plugins/wk-google-analytics/
5
  Description: Google Analytics for WordPress without tracking your own visits
6
- Version: 1.0
7
  Author: WebKinder
8
  Author URI: http://www.webkinder.ch
9
  License: GPL2
@@ -29,8 +29,87 @@ class wk_ga {
29
  //Cookie Handling
30
  add_action( 'admin_enqueue_scripts', array( $this, "load_admin_scripts" ) );
31
 
32
- //Load GA Code on Frontend
33
- add_action( 'wp_footer', array( $this, "render_ga_script" ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  }
35
 
36
  /*
@@ -45,8 +124,6 @@ class wk_ga {
45
  */
46
  public function activation() {
47
 
48
- //set setting defaults
49
- update_option( 'track_logged_in', false );
50
  }
51
 
52
  /*
@@ -54,8 +131,6 @@ class wk_ga {
54
  */
55
  public function deactivation() {
56
 
57
- //remove cookie
58
-
59
  }
60
 
61
  /*
@@ -63,14 +138,30 @@ class wk_ga {
63
  */
64
  public function register_settings() {
65
  register_setting(
66
- 'wk_ga_google_analytics', // settings section
67
- 'ga_tracking_code' // setting name
68
  );
69
 
70
  register_setting(
71
- 'wk_ga_google_analytics', // settings section
72
- 'track_logged_in' // setting name
73
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  }
75
 
76
  /*
@@ -92,44 +183,13 @@ class wk_ga {
92
 
93
  //translate JavaScript
94
  $translation_array = array(
95
- 'UntrackText' => __('Page visits from this device are not tracked.','wk-ga'),
96
- 'TrackText' => __('This device is treated like any other','wk-ga')
97
  );
98
  wp_localize_script('wk-ga-admin-js', 'text_content', $translation_array );
99
  wp_enqueue_script('wk-ga-admin-js');
100
 
101
  }
102
 
103
- public function render_ga_script() {
104
- $GA_CODE = get_option('ga_tracking_code');
105
- $TRACK_LOGGED_IN = get_option('track_logged_in');
106
-
107
- if( $GA_CODE && ( (!$TRACK_LOGGED_IN && !is_user_logged_in()) || $TRACK_LOGGED_IN ) ) :
108
- ?>
109
-
110
- <script>
111
-
112
- if( !
113
- (new RegExp('wp_wk_ga_untrack_' + document.location.hostname) ).test(document.cookie)
114
- )
115
- {
116
- console.log('THIS VISIT GETS TRACKED');
117
-
118
- //GA Tracking Snippet
119
- (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
120
- (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
121
- m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
122
- })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
123
- ga('create', '<?php echo $GA_CODE; ?>', 'auto');
124
- ga('send', 'pageview');
125
- }
126
- </script>
127
-
128
- <?php
129
-
130
- endif;
131
- }
132
-
133
  /*
134
  * Settings Page
135
  */
@@ -144,6 +204,7 @@ class wk_ga {
144
  }
145
 
146
  public function settings_content() {
 
147
  if ( ! isset( $_REQUEST['settings-updated'] ) )
148
  $_REQUEST['settings-updated'] = false;
149
  ?>
@@ -155,29 +216,40 @@ class wk_ga {
155
  </div>
156
  <?php endif; ?>
157
 
158
- <p><?php _e('Enter your Google Analytics tracking code below. There are two additional mechanisms that allow you to stop tracking your own visits. The first one checks if you are logged in as a WordPress User. The second one allows you to stop tracking certain devices totally by setting a cookie.', 'wk-ga'); ?>
159
  </p>
160
-
161
- <form id="wk-google-analytics-settings" method="post" action="options.php">
162
- <?php settings_fields( 'wk_ga_google_analytics' ); ?>
163
- <?php do_settings_sections('wk_ga_google_analytics'); ?>
164
-
165
- <div>
166
- <label><?php _e('GA Tracking Code', 'wk-ga'); ?></label>
167
- <input type="text" name="ga_tracking_code" value=<?php echo esc_attr( get_option( "ga_tracking_code" ) ); ?> />
168
- </div>
169
- <div>
170
- <label><?php _e('Track logged in users', 'wk-ga'); ?></label>
171
- <input type="checkbox" name="track_logged_in" value="1" <?php checked( get_option( "track_logged_in" ) )?> />
172
- </div>
173
- <?php submit_button(); ?>
174
- </form>
175
-
176
- <div>
177
- <p></p>
178
- <div id="track-device"></div>
179
- </div>
180
-
 
 
 
 
 
 
 
 
 
 
 
181
  </div>
182
 
183
  <?php
3
  Plugin Name: Google Analytics by WebKinder
4
  Plugin URI: https://wordpress.org/plugins/wk-google-analytics/
5
  Description: Google Analytics for WordPress without tracking your own visits
6
+ Version: 1.5
7
  Author: WebKinder
8
  Author URI: http://www.webkinder.ch
9
  License: GPL2
29
  //Cookie Handling
30
  add_action( 'admin_enqueue_scripts', array( $this, "load_admin_scripts" ) );
31
 
32
+ //Cookie function
33
+ add_action( 'wp_head', array( $this, 'render_script') );
34
+
35
+ //Google Analytics code in <head>
36
+ add_action( 'wp_head', array( $this, 'google_analytics_script') );
37
+
38
+ //Google Tag Manager in footer
39
+ add_action( 'wp_footer', array( $this, 'google_tag_manager_script'));
40
+ }
41
+
42
+ /*
43
+ * Should Track Visit
44
+ */
45
+ function should_track_visit() {
46
+ return ( !is_user_logged_in() || get_option('track_logged_in') );
47
+ }
48
+
49
+ /*
50
+ * Render Script
51
+ */
52
+ function render_script() {
53
+ ?>
54
+ <script>
55
+ function hasWKGoogleAnalyticsCookie() {
56
+ return (new RegExp('wp_wk_ga_untrack_' + document.location.hostname) ).test(document.cookie);
57
+ }
58
+ </script>
59
+ <?php
60
+ }
61
+
62
+ /*
63
+ * Tag Manager Script Tag
64
+ */
65
+ function google_tag_manager_script() {
66
+ if( $this->should_track_visit() && get_option('ga_use_tag_manager') ) {
67
+ $TAG_MANAGER_ID = get_option('ga_tag_manager_id');
68
+ ?>
69
+ <noscript><iframe src="//www.googletagmanager.com/ns.html?id=<?php echo $TAG_MANAGER_ID; ?>"
70
+ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
71
+ <script>
72
+ if( !hasWKGoogleAnalyticsCookie() ) {
73
+ //Google Tag Manager
74
+ (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
75
+ new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
76
+ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
77
+ '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
78
+ })(window,document,'script','dataLayer','<?php echo $TAG_MANAGER_ID; ?>');
79
+ }
80
+ </script>
81
+ <?php
82
+ }
83
+ }
84
+ /*
85
+ * Google Analytics Script Tag
86
+ */
87
+ function google_analytics_script() {
88
+ if( $this->should_track_visit() && ! get_option('ga_use_tag_manager') ) {
89
+ $GA_TRACKING_CODE = get_option('ga_tracking_code');
90
+ $ANONYMIZE_IP = get_option('ga_anonymize_ip');
91
+ ?>
92
+ <script>
93
+ if( !hasWKGoogleAnalyticsCookie() ) {
94
+ //Google Analytics
95
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
96
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
97
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
98
+ })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
99
+ ga('create', '<?php echo $GA_TRACKING_CODE; ?>', 'auto');
100
+ <?php
101
+ if( $ANONYMIZE_IP ) :
102
+ ?>
103
+ //anonymize IP
104
+ ga('set', 'anonymizeIp', true);
105
+ <?php
106
+ endif;
107
+ ?>
108
+ ga('send', 'pageview');
109
+ }
110
+ </script>
111
+ <?php
112
+ }
113
  }
114
 
115
  /*
124
  */
125
  public function activation() {
126
 
 
 
127
  }
128
 
129
  /*
131
  */
132
  public function deactivation() {
133
 
 
 
134
  }
135
 
136
  /*
138
  */
139
  public function register_settings() {
140
  register_setting(
141
+ 'wk_ga_google_analytics',
142
+ 'ga_tracking_code'
143
  );
144
 
145
  register_setting(
146
+ 'wk_ga_google_analytics',
147
+ 'track_logged_in'
148
  );
149
+
150
+ register_setting(
151
+ 'wk_ga_google_analytics',
152
+ 'ga_anonymize_ip'
153
+ );
154
+
155
+ register_setting(
156
+ 'wk_ga_google_analytics',
157
+ 'ga_use_tag_manager'
158
+ );
159
+
160
+ register_setting(
161
+ 'wk_ga_google_analytics',
162
+ 'ga_tag_manager_id'
163
+ );
164
+
165
  }
166
 
167
  /*
183
 
184
  //translate JavaScript
185
  $translation_array = array(
186
+ 'TrackText' => __('Do not track any visits from this device.','wk-ga')
 
187
  );
188
  wp_localize_script('wk-ga-admin-js', 'text_content', $translation_array );
189
  wp_enqueue_script('wk-ga-admin-js');
190
 
191
  }
192
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  /*
194
  * Settings Page
195
  */
204
  }
205
 
206
  public function settings_content() {
207
+
208
  if ( ! isset( $_REQUEST['settings-updated'] ) )
209
  $_REQUEST['settings-updated'] = false;
210
  ?>
216
  </div>
217
  <?php endif; ?>
218
 
219
+ <p><?php _e('Enter your Google Analytics tracking code below. You can also use Google Tag Manager instead by checking the relevant setting.', 'wk-ga'); ?>
220
  </p>
221
+ <div class="wk-left-part">
222
+ <form id="wk-google-analytics-settings" method="post" action="options.php">
223
+ <?php settings_fields( 'wk_ga_google_analytics' ); ?>
224
+ <?php do_settings_sections('wk_ga_google_analytics'); ?>
225
+
226
+ <div class="use-google-analytics">
227
+ <label><?php _e('GA Tracking Code', 'wk-ga'); ?></label>
228
+ <input type="text" name="ga_tracking_code" placeholder="UA-XXXXXXXX-X" value="<?php echo esc_attr( get_option( "ga_tracking_code" ) ); ?>" />
229
+ </div>
230
+ <div class="use-google-analytics">
231
+ <label><?php _e("Anonymize IP's", 'wk-ga'); ?></label>
232
+ <input type="checkbox" name="ga_anonymize_ip" value="1" <?php checked( get_option( "ga_anonymize_ip") ); ?> />
233
+ </div>
234
+ <div>
235
+ <label><?php _e('Track logged in users', 'wk-ga'); ?></label>
236
+ <input type="checkbox" name="track_logged_in" value="1" <?php checked( get_option( "track_logged_in" ) ); ?> />
237
+ </div>
238
+ <div>
239
+ <label><?php _e("Use Google Tag Manager instead", 'wk-ga'); ?></label>
240
+ <input id="use-google-tag-manager" type="checkbox" name="ga_use_tag_manager" value="1" <?php checked( get_option( "ga_use_tag_manager") ); ?> />
241
+ </div>
242
+ <div class="use-google-tag-manager">
243
+ <label><?php _e("Google Tag Manager ID", 'wk-ga'); ?></label>
244
+ <input type="text" name="ga_tag_manager_id" placeholder="GTM-XXXXXX" value="<?php echo esc_attr( get_option( "ga_tag_manager_id" ) ); ?>" />
245
+ </div>
246
+ <div id="track-device"></div>
247
+ <?php submit_button(); ?>
248
+ </form>
249
+ </div>
250
+ <div class="wk-right-part">
251
+ <?php include_once( __DIR__ . "/includes/mailchimp-form.php" ); ?>
252
+ </div>
253
  </div>
254
 
255
  <?php