Posts: 36
Threads: 3
Joined: Sep 2011
2011-09-07, 01:56:03
(This post was last modified: 2011-09-30, 07:39:21 by zintonio.)
Here is my first plugin for GetSimple: Google Analytics 0.1. The purpose of this plugin is to provide an easy way to add Google Analytics tracking code to your GetSimple site, without tracking logged in admin users. When an admin cookie is detected, the plugin will remove the tracking code so that site admins will not influence Google Analytics visitor statistics.
How to use: Go to Theme->Google Analytics, and enter your Google Analytics property ID.
This is a relatively simple plugin, but I'm releasing it here for testing before I upload it to extend. Success reports, constructive criticism, and suggestions for improvement are all welcome.
I've tested this plugin on 3.0 and 3.1B r533. I have not done any testing for compatibility with multi-user plugins.
Todo:- Possible integration with multi-user plugins, with options not to track users besides the admin
- Maybe an option to disable tracking on an admin's machine even when they are no longer logged into GS
- Add better documentation on how a user can find their site's Google Analytics property ID
- Integration with the extend API to automatically check for and notify about updates
*** Update: New version available. See the end of this thread. ***
Posts: 36
Threads: 3
Joined: Sep 2011
Okay, for some reason it won't upload files that I attach to the post. Here's an external link instead: http://dl.dropbox.com/u/172392/google_analytics.php
Posts: 2,094
Threads: 54
Joined: Jan 2011
filupn Wrote:Okay, for some reason it won't upload files that I attach to the post. Here's an external link instead: http://dl.dropbox.com/u/172392/google_analytics.php
You probably forgot to click on "Add file" ;-)
Posts: 36
Threads: 3
Joined: Sep 2011
2011-09-07, 02:37:16
(This post was last modified: 2011-09-30, 07:24:50 by zintonio.)
mvlcek Wrote:You probably forgot to click on "Add file" ;-)
Oh, you're right. Thanks!
Here it is now:
***Update: Attachment removed. Download the latest version at the end of this thread.***
Posts: 661
Threads: 52
Joined: Feb 2011
filupn Wrote:Here is my first plugin for GetSimple: Google Analytics 0.1. The purpose of this plugin is to provide an easy way to add Google Analytics tracking code to your GetSimple site, without tracking logged in admin users. When an admin cookie is detected, the plugin will remove the tracking code so that site admins will not influence Google Analytics visitor statistics.
How to use: Go to Theme->Google Analytics, and enter your Google Analytics property ID.
This is a relatively simple plugin, but I'm releasing it here for testing before I upload it to extend. Success reports, constructive criticism, and suggestions for improvement are all welcome.
I've tested this plugin on 3.0 and 3.1B r533. I have not done any testing for compatibility with multi-user plugins.
Todo:- Possible integration with multi-user plugins, with options not to track users besides the admin
- Maybe an option to disable tracking on an admin's machine even when they are no longer logged into GS
- Add better documentation on how a user can find their site's Google Analytics property ID
- Integration with the extend API to automatically check for and notify about updates
Great, You already made your first plugin!
Thanks for your contribution, it has saved me time. I like the possibility of tracking users in the future.
Posts: 36
Threads: 3
Joined: Sep 2011
I am releasing version 0.2 of the Google Analytics plugin.
Changes since 0.1: - Added ability not to track users even after they have logged out of the GetSimple admin area
- Moved plugin settings page from "Theme" to "Plugins" in the site admin area
- Added a link on the plugin settings page for users to learn how to find their profile ID
- Miscellaneous minor changes and code improvements
I have tested it with GS version 3.0 and 3.1 beta.
Download from its page on GetSimple Extend.
Posts: 36
Threads: 3
Joined: Sep 2011
Just wanted to let everyone know that I've tested this with the Multi-User plugin and I did not find any issues. No users will be tracked by Google Analytics in a multi-user setup.
Posts: 10
Threads: 1
Joined: Jan 2012
Hello everyone,
Thanks for this plug in, I guess I might be the only one to have a problem with it Hope it is nothing serious though.
I am under Getsimple CMS v3. I can't have google analytics recognize the tracking code on the getsimple pluggin.
- Before you give me the "RTFM" link that is on setting page... I tried this:
Code looks like this: UA-XXXXXXXX-X
So I tried as explained in the help page: only entering the 8 middle numbers.
I also tried all the code, and also middle and last number separated by the "-".
Seems that it is not working. I am not an expert but I gave a peek in to the googleanalytics.php pluggin files and at the beginning there is a mention of a data files to save info called: googleanalyticssettings.xml
I don't know where it is supposed to be ? In the folder called google analytics that you have in the pluggin folder ?
It is definitly empty for me.
Now I know that my hosting is also pretty restrictive on permission. It might be only a problem of writting rules. Does your pluggin need special writting permissions and on which files ?
Thank you for your help,
Sarah
Posts: 36
Threads: 3
Joined: Sep 2011
Hi Sarah,
I don't think my instructions for how to enter the Google Analytics property ID were very clear. The correct format is "UA-12345678-1", including the "UA-" at the beginning and the "-1" at the end. I've added a note on my instructions page clarifying that.
If the plugin is saving the value you enter, and that value appears in the settings box after you save the settings, the permissions are fine.
Keep in mind that you won't be able to see the Google Analytics data immediately. There's a delay from when it's collected by Google, and when you can view it in your Google Analytics dashboard. In other words, don't expect to be able to hit refresh in your browser and immediately go over to your Google Analytics dashboard and see that hit show up in the logs. There's a delay of a couple hours or even days. This is how Google works, it's not a limitation in the plugin.
So it could be that everything is working fine, you just can't see the data in Google Analytics for a day or two so it looks like something's broken.
If you give me the URL of the site, I can check and see if the GA tracking code is being added to the page properly, and if so, it's just a matter of time until you see the data.
Posts: 10
Threads: 1
Joined: Jan 2012
Hello,
Thank you for the answer. So I changed the code to include all the informations.
Now before I posted on the forum I waited already 1 days as I am well aware that google analytics needs minimum 24hours before it can process any data or sometime detect your pages codes.
But during this day I kept on following up the help page and entered only the 8 middle digits ( as shown in the pictures there ). So that is probably why it didn't work
I updated the settings with the full code, and will wait.
the website is: www.travellerspalm-kl.com
Thank you for your answer, let's hope it was just as simple as that !
Posts: 36
Threads: 3
Joined: Sep 2011
The Google Analytics tracking section looks fine on your site, so all should be good now. Thanks for bringing that to my attention so I could clarify my documentation, and sorry for your frustration!
Let me know if it's working after you give it some time.
Posts: 10
Threads: 1
Joined: Jan 2012
Great thanks for your support !
No worries frustration is something you need to live with when you begin creating websites sometimes, especially when you are not a pro
I will get back to you in a couple of days as soon as I get some datas in !
Posts: 10
Threads: 1
Joined: Jan 2012
Hi,
It has been a couple of days and google analytics still doesn't recognize the code and plugins. On the administration page I get the "unconfigured code". So I guess something went wrong. Are you sure there is not at any point a writting action that went wrong ? That wouldn't be the first time I have problem with permissions on hostings...
Or maybe google analytics updated their general code ?
This is the code I am supposed to copy paste into my page:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-MYCODE']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
Is it the same that is in your plugin or at one point maybe they did an update of some sort... ? I don't know what information I need to give you to help you "help me"
Thanks again
Posts: 36
Threads: 3
Joined: Sep 2011
It looks to me like the code that is being output by the plugin is correct. This is what I'm seeing in the page source of your site:
Code: <script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA–28725173–1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
Could it be that your site hasn't gotten any visitors besides you, so GA hasn't collected any data? If the "Remember me when logged out of GetSimple and don't add tracking code" checkbox is turned on in the plugin settings page (and it is by default), then GA will not track you, even when you're logged out of the admin area.
If you want to see the code that the plugin is outputting, you can turn that checkbox off, and log out of GetSimple, and then view the page source in your browser. Then in the "head" section you should see the GA tracking code that the plugin is outputting, which looks correct to me. You could also just visit the site in a different browser that you haven't ever used to log in to your site, and view source there to see the code.
When I view source on your site, it looks to me like the plugin is doing everything it's supposed to do, so the next thing I would question is whether you're getting visitors to the site besides you, since the plugin doesn't track people who have logged into the admin area.
Posts: 10
Threads: 1
Joined: Jan 2012
Hi,
Thank you for your answer. No this website before I updated it from html pages to getsimple had about 1500 visitors a month, so I am doubting I would be the only one visiting it.
What troubles me most, is that the robot from google analytics doesn't aknowlegde the code on the pages at all, as I get this " unconfigured code" message on the administration page.
I will uncheck the options you mention for the next few days and see if it shows some results.
Then I think this musn't be your plugin... I will dig around the internet and see what I can find. This is really strange I am the only one coming with this problem, so maybe I should look for a more "unique" issue.
Thanks for the support. If it doesn't work, I will just install the hitcount plug in, it should be enough for the owner of the website. I was just keen on using google analytics as I am more familiar with it.
Posts: 36
Threads: 3
Joined: Sep 2011
Ahah! I found something!
Looking closer at the code in your site, I noticed that the dashes in your Google Analytics property ID are a different kind of dash than what is normally used.
What you have is
Code: UA–28725173–1
and what you want is
It's hard to see, but they are different dashes.
Maybe your keyboard is sending the wrong dash? I'm not very familiar with i18n stuff. Anyway, paste the code with the correct dashes into the plugin settings and everything should work now.
Posts: 36
Threads: 3
Joined: Sep 2011
sarahflo Wrote:Then I think this musn't be your plugin...
Actually, it is my plugin.
Posts: 10
Threads: 1
Joined: Jan 2012
Hi,
Thanks for your quick answer ! It is true I had some strange dashes on my page. I changed it. So I guess I will leave it this way for a couple of days and see if something change.
Else I tried some internet search related to my hosting company and google analytics. And it could also be a problem of conflict between GA and Urchin that my hosting is using on their server.... ( something about ga.js files )
It is strange though as I have many websites hosted on this hostings and never had any trouble with GA before...
I will wait for a couple of days and then maybe look into that direction !
Anyway, thanks for your answers and quick support, I really appreciate it.
I will keep you posted of what I find out or if I decide to give up and just go for the hitcount plugin.
Hope this is just the dashes though !
Posts: 10
Threads: 1
Joined: Jan 2012
AH ! Victory !
It was just the dashes... Google analytics finally changed the administration status to "Code configured"... Now it is just a matter of time before the first datas are in !
If I had known this was just about this simple thing...
Thanks for your time ! I am always amazed how some problems seem big when the cause is so small
( and thinking I was going for sooo complicated explanations... )
Conclusion: French keyboard is evil.
Posts: 36
Threads: 3
Joined: Sep 2011
sarahflo Wrote:AH ! Victory !
Great! Glad it's working now.
Posts: 16
Threads: 1
Joined: Oct 2012
Thanks for the plugin, works great!
Any chance you have the code on github (or bitbucket..etc)? Would love to add some additional properties in the admin panel (well, really just want setSampleRate at this point - helps with page timings for sites that don't get much traffic)
Posts: 2
Threads: 0
Joined: May 2013
Is there a delay from the time you put the Google Analytics property ID in GetSimple admin to the time it shows up on the site?
Posts: 3,491
Threads: 106
Joined: Mar 2010
There shouldn't be.
Does you template have a <?php get_header(); ?> tag?
Posts: 2
Threads: 0
Joined: May 2013
(2013-05-03, 01:39:44)Carlos Wrote: There shouldn't be.
Does you template have a <?php get_header(); ?> tag?
Thanks for the quick response...my webpage did not have the get_header tag. It does now however and it is working great!
Thanks again for your help.
Posts: 16
Threads: 1
Joined: Oct 2012
Any plans for updating this to use Universal Analytics?
|