Module: Google Analytics Module

mcp

Joined: 2009-07-06
Posts: 3
Posted: Mon, 2009-07-06 22:48

Hi,

I've created a little Module which renders the Google Analytics Code at the end of each page.
You can enter the required Web-Property-ID at the Administration-Panel under Settings/Google Analytics.

I have hidden the attachment to this post as it does not work with the latest version of G3.
@mcp: the original attachment is still in this post just hidden, so if you care to continue development you still can.
See: http://gallery.menalto.com/node/88884#comment-355848 for a version that seems to work.
- floridave

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Mon, 2009-07-06 23:14

Cool, only briefly looked at the code. Does it support SSL?
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
mcp

Joined: 2009-07-06
Posts: 3
Posted: Mon, 2009-07-06 23:33

I only copied the original Google code which supports SSL afaik

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Mon, 2009-07-06 23:36

ah, perfect, looking at google_analytics_theme.php it appears it should be just fine. I'll have to test this out once I get my ssl cert on my new server.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2009-07-07 23:21

Great! Thanks for the contribution. Can you create a codex page for this module? That would help out a bunch.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
mcp

Joined: 2009-07-06
Posts: 3
Posted: Tue, 2009-07-07 23:53
 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2009-07-08 02:21

Thanks!

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Sun, 2009-07-12 16:13

Great work! I've added this to our contrib repository here:
http://github.com/gallery/gallery3-contrib/tree/3ec8ccfff8e1dbffc5d24d22976579b79aee6ade/modules/google_analytics

I did some minor style cleanup to get it in line with our current style, and I tweaked the installer a bit. If you'd like to make changes there, create a fork, make changes, then submit a pull request and I'll pull them in.
---
Problems? Check gallery3/var/logs
bugs/feature req's | upgrade to the latest code | use git | help! vote!

 
toxen

Joined: 2009-06-12
Posts: 4
Posted: Wed, 2009-10-21 00:37

I'm having a problem with adding this one.
After activating the module it doesn't show up in the 'Settings' menu.

EDIT: Got it working via /gallery3/index.php/admin/google_analytics. But it's still not showing up in the Settings drop-down menu.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2009-10-21 02:47

Seems to work for me. At lease the code is added to my page, don't know if it works or is correct but the code does get added.
Try an experimental version of G3:
FAQ: How do I upgrade?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
hebhansen
hebhansen's picture

Joined: 2009-02-10
Posts: 573
Posted: Thu, 2009-11-26 08:13

Brilliant module here ... thanks. Statistics are roling in :-)

and what a nice presentation by Google analytics. This is a must have for anyone that wish to learn and improve from your site trafic.

I wondered: Does the module track admin traficking? That will ofcourse influence statistics in a non-realistic way. Could this be changed if in case, so that admin trafic is left out of the loop

all the best
HB - http://www.image.agentura.dk

 
hebhansen
hebhansen's picture

Joined: 2009-02-10
Posts: 573
Posted: Wed, 2009-12-02 15:33

Note: statistics for Lightbox triggered image views are not triggered. Should this be handled by the theme or this module?

I posted this for 3nids theme:
<quote>
Images are triggered in the light box. Therefore, view count is not triggered. I get statistics for viewed albums, next, previous etc. Image views is not tracked... and views are indicated as 0 views.

Can this be fix'ed for Gallery as well as googleanalytics module???
</quote>
all the best
HB - http://www.image.agentura.dk

 
rojer_31

Joined: 2009-01-13
Posts: 12
Posted: Fri, 2010-01-08 09:18

A request:
Recently google had released an asynchronous version of their analytics code (snippet). Since we are using that & that code has to be included before the </head>, we cannot use this module.

More info:
http://code.google.com/apis/analytics/docs/tracking/asyncTracking.html
http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=161379

Will implementing this be possible?

Thank you!

 
Velociped
Velociped's picture

Joined: 2009-12-25
Posts: 58
Posted: Fri, 2010-02-05 17:58

[img]http://www.imagehut.eu/images/99142ga_gallery.gif[/img]

By default it just shows an empty field and there's no link to click on.

I can change the (empty) value by using:
gallery3/index.php/admin/advanced_settings/edit/google_analytics/code
But this is probably not the way it should be. ;-)

Is it true that I only have to enter my tracking-code and not the whole script provided by Google?

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Fri, 2010-02-05 18:04
Quote:
By default it just shows an empty field and there's no link to click on.

This should be fixed. Please grab the latest experimental code:
http://github.com/gallery/gallery3/zipball/master

Upgrading instructions here:
http://codex.gallery2.org/Gallery3:Upgrading

Bug info here: http://sourceforge.net/apps/trac/gallery/ticket/987
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
Shemo725

Joined: 2008-04-18
Posts: 424
Posted: Sun, 2010-06-20 21:00

google analytics does not show up under settings after activating the module. I had to go into the advanced settings to enter my UA number. I'm on the experimental code as of last night, 6/19/10.

 
snackmaster
snackmaster's picture

Joined: 2005-11-20
Posts: 135
Posted: Mon, 2010-08-09 20:52

I had to do what Shemo725 did - I'm running 3.0 RC2 (Santa Fe).
I was also able to hit this URL and enter my Google code: /gallery/admin/google_analytics.
If either of the above was done the code showed up on all Gallery pages above the footer section in my Theme.

Once the above is working, it would be very nice to see stat charts and data displayed within the Admin.

 
Velociped
Velociped's picture

Joined: 2009-12-25
Posts: 58
Posted: Sat, 2010-10-09 21:06

After upgrading gallery from Version #21 to #41 (V3.0) I got an error for the google_analytics module!

An error occurred while installing the Google Analytics module

Anybody else with the same problem?

 
surgeon

Joined: 2005-01-18
Posts: 80
Posted: Sun, 2010-10-10 10:10

I had the same problem. Module was probably not adapted to the latest version.

 
snackmaster
snackmaster's picture

Joined: 2005-11-20
Posts: 135
Posted: Sun, 2010-10-10 14:08

Working for me, I'm running Analytics v2 and final release of G3.
After upgrading a banner appeared in the admin notifying of available module upgrades and linked to an auto upgrade page (nice!) and I upgrade from Analytics v1 to 2.

 
munozj

Joined: 2006-02-22
Posts: 12
Posted: Sun, 2010-10-10 16:30

I'm having a strange issue with the gallery3 auto updater.

I'm seeing this message:
Some of your modules are out of date. Upgrade now!

But when I click on Upgrade now, it's showing
Module name: Installed version Available version
Gallery 3: 41, 41
Google Analytics: , 1.2

No version indicated in the installed version so G3 continues to think i'm out-dated.

I'm just ignoring the message for now but did i setup it up wrong?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2010-10-11 16:54

There was some issues with this module and the above .zip file does not work right.
I have fixed it below in the attachment:

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
surgeon

Joined: 2005-01-18
Posts: 80
Posted: Mon, 2010-10-11 17:13

Module activated, but where are the settings?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2010-10-11 17:39

Did you read the documentation?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
surgeon

Joined: 2005-01-18
Posts: 80
Posted: Mon, 2010-10-11 18:23

You mean this "After activation, you can setup the module under Settings -> Google Analytics."?

As I wrote earlier (maybe not too clear), I do not have such a choice on the menu.

 
Velociped
Velociped's picture

Joined: 2009-12-25
Posts: 58
Posted: Thu, 2010-10-14 17:08
floridave wrote:
I have fixed it below in the attachment:

Thanks Dave! Great!
Everything's fine now! :-)

What do you think, is it possible to make the current version downloadable from the website too, rather than just from the forum? http://codex.gallery2.org/Gallery3:Modules:google_analytics

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2010-10-15 02:44

fixed the codex page to point to my post. Is that what you are after?
I have asked bharat to update the GIT as well, b ut he is out of town for the next few days.

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
Velociped
Velociped's picture

Joined: 2009-12-25
Posts: 58
Posted: Fri, 2010-10-15 22:10
floridave wrote:
Is that what you are after?

More or less, yes! I just love to have a direct download-link. [img]http://img88.imageshack.us/img88/4148/zwinker.gif[/img]
Otherwise everybody has to skim all the posts in this thread first, just to get the files. And I'm always a bit unsure if I really got the latest version?! This would be much more convenient with a direct link.

 
petri
petri's picture

Joined: 2005-12-15
Posts: 253
Posted: Mon, 2010-10-18 10:48

Hello Dave,

Just as surgeon, I don't have any "Google Analytics" in my Settings menu.

I just can find it in the "advanced" menu.

So what should I put as the code : is it just the client number or the hole code that Google Analytics suggest you to paste at the end of your pages ?

such as :

Quote:
<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'your client number']);
_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>

thank you in advance for your answer

-----------------

 
photografx
photografx's picture

Joined: 2010-09-16
Posts: 2
Posted: Wed, 2010-10-20 18:17

Hi Dave ...

same problem here ...
no entry in the settings menu ...
gallery3 version 41 ...
google analytics version 2.0 ...

cheers
Alexx

started with G1 and NO knowledge -
now CSS-styling of G2/G3

 
Albin11z

Joined: 2010-10-21
Posts: 3
Posted: Thu, 2010-10-21 17:32

I am not sure this is correct but I went to Modules and then checked the box next to "Google Analytics 2 Renders the Google Analytics Code at the end of the page." then I clicked the update box at the bottom. After that I went to Settings=>Advanced=>scrolled down to "google_analytics code " and clicked on the word "empty". when you click on the word empty you get a pop-up box (check your pop up blocker) and in the box that says "code" I enter my "Profile ID #". Like I said, am not sure if this is correct or not.

 
surgeon

Joined: 2005-01-18
Posts: 80
Posted: Fri, 2010-10-22 11:04

Albin11z: Maybe this is correct, but we don`t have `Settings=>Advanced=>scrolled down to "google_analytics code"`.

 
haides

Joined: 2010-09-22
Posts: 3
Posted: Sun, 2010-10-24 13:15
Albin11z wrote:
I am not sure this is correct but I went to Modules and then checked the box next to "Google Analytics 2 Renders the Google Analytics Code at the end of the page." then I clicked the update box at the bottom. After that I went to Settings=>Advanced=>scrolled down to "google_analytics code " and clicked on the word "empty". when you click on the word empty you get a pop-up box (check your pop up blocker) and in the box that says "code" I enter my "Profile ID #". Like I said, am not sure if this is correct or not.

It worked for me with G3 final build. Thanks

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2010-10-24 22:04

Typo try
http://gallery.menalto.com/files/google_analytics_0.zip

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
haides

Joined: 2010-09-22
Posts: 3
Posted: Mon, 2010-10-25 01:29

Thanks.

 
surgeon

Joined: 2005-01-18
Posts: 80
Posted: Mon, 2010-10-25 07:44

Solved. :)

 
Albin11z

Joined: 2010-10-21
Posts: 3
Posted: Mon, 2010-10-25 13:51
floridave wrote:
Typo try
http://gallery.menalto.com/files/google_analytics_0.zip

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

I downloaded the new zip file from "http://gallery.menalto.com/files/google_analytics_0.zip" and then removed the previously uploaded version and uploaded the new version, but There was no difference. I then decided to compare the files using hash values. I compared "http://gallery.menalto.com/files/google_analytics_0.zip" to the google_analytics.zip I downloaded prior to the "typo try" post and the hash values for each and every file was identical (meaning there was no difference).

The only difference was the folder name google_analytics and google_analytics_0 So I removed google_analytics and uploaded google_analytics_0 to see if I would get better results, and as I suspected there still is no difference.

Surgeon... any chance you can tell me what you did to get it working.

 
surgeon

Joined: 2005-01-18
Posts: 80
Posted: Mon, 2010-10-25 20:39

Albin11z: simply overwrite the old files with new ones.

 
Albin11z

Joined: 2010-10-21
Posts: 3
Posted: Mon, 2010-10-25 20:45

I did that, but nothing changed. I also compare the old files and the new files using a HASH compare and found the files to be identical. So over writing ifles with the same file is not going to change anything.

 
pwsva
pwsva's picture

Joined: 2010-12-06
Posts: 1
Posted: Mon, 2010-12-06 12:26

I found that adding a folder under the modules folder, I named it "googleanal" and then extracted files to this folder the modules page showed the "Google Analytics" option.

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Thu, 2011-02-10 15:23

I just registered for Google Analytics and the code they just gave me to include was somewhat different to what the module produces. GA doesn't seem to be detecting the module's code. It won't be hard to update the module, but before I do this has anyone else found this? Am I right in concluding that GA has changed its code recently?

U-G

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Thu, 2011-02-10 23:51

Yesterday this didn't seem to be working but today it is. I still have the impression that there is a newer version of the GA code, and I suspect that the module will need to be updated at some stage. The code I was given when I signed up to GA was:

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'xxxxxxxxxx']);
  _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>

whereas the module uses

<script type="text/javascript"> 
	var gaJsHost = (("https:" == document.location.protocol) ?
	"https://ssl." : "http://www.");
	document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
	try
	{
		var pageTracker = _gat._getTracker("xxxxxxx");
		pageTracker._trackPageview();
	}
	catch(err){}
</script>

The other option that would be nice to include in the module would be the ability to disable the code for the image owner or admin or whatever. I guess that shouldn't be hard.

U-G

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2011-02-11 00:43

The original author does not seem to be keep up to date, so, care to take over development/updates to the module?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Fri, 2011-02-11 00:58

I guess so. I don't think it *needs* any changes at the moment. I need to better understand the differences in the two versions of the GA code before I go making any new changes. The code to disable owner views is fairly simple. I might try and include it in the admin module as a learning exercise. But it's my turn to travel and this will have to wait.

U-G

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Sat, 2011-02-12 08:12

I managed to find some time before I left to code a new version (version 3). This version uses the latest version of the Google Analytics code. I've also added an option in the module's admin page to disable the GA code if the viewer is either the active user or an admin.

It seems to be working, but if anyone has problems with this new version in the next week or so while I am travelling I may or may not be in a position to assist.

There are in fact two versions of the GA code, with the other one being what you use if you have multiple sites under the one domain - e.g. www.mydomain.com and gallery.mydomain.com and perhaps also blog.mydomain.com. I'll have a go at adding this option after I have solved some more general problems with .html suffixes.

If anyone has the .html suffix option enabled in config.php then you may need to temporarily disable it in order to access the admin page for this module. Once you've set the options for the GA module, then you can turn html back on - as this GA module works fine with that html suffix config option. [I have two sites - a production site plus a test site that is a clone of the prod site - and on the test site I don't need to disable .html to access this module's admin page, but I do on the virtually identical production site. Go figure!]

U-G

Edit: I've worked out why the GA code in this new version of the module is different to that in the initial version - Google changed the code in Dec 2009 to asynchronous code to speed things up. Details here: http://googlecode.blogspot.com/2009/12/google-analytics-launches-asynchronous.html

So this should speed things up a little - in theory.

 
Shai

Joined: 2003-12-10
Posts: 61
Posted: Thu, 2011-02-24 21:03

Thanks! Giving it a go ... :)

 
ash_kh

Joined: 2011-01-15
Posts: 13
Posted: Mon, 2011-08-29 15:55

Hi I've recently installed this module with the latest gallery release, but GA is not tracking the gallery pages at all. I also use the same tracking code for the domain e.g. www.domain.co.uk (which tracks fine) and www.domain.co.uk/gallery3. It's not a sub-domain so that shouldn't cause issues but I don't know why else it wouldn't track? Any suggestions appreciated.

ETA - Solved. I had to create a separate profile for the gallery and the domain and track them as though they were two different sites.

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Mon, 2012-07-23 18:40

Comments are now permitted for this topic.

 
Liquid_Squelch

Joined: 2006-09-10
Posts: 15
Posted: Mon, 2012-07-30 12:06

I just downloaded this module for my gallery3 install that is on a subdomain.
According to a page source, I can see the GA code presented at the bottom of the page, but my Google Analytics Admin console still says the code is missing.

The only difference I can see is that the Google Code has single quotes, but my page source shows double quotes around the code.

my gallery is at http://gallery.w2lie.net

Thanks

 
ahopple

Joined: 2013-01-29
Posts: 1
Posted: Tue, 2013-01-29 20:20

I just downloaded and extracted it into the modules directory, but am unable to see it in the modules page. I put another module in there to see if it would show up (adsense) and it showed up just fine... i tried changing the directory name to googlea and that didn't work either...

 
alokps

Joined: 2013-01-31
Posts: 1
Posted: Thu, 2013-01-31 17:40

Anything for adwords conversion tracking?