Google Analytics on login pages

Google Analytics on login pages, a forum discussion on Jojo CMS. Join us for more discussions on Google Analytics on login pages on our Suggestions & Feedback forum.

Back to Forum Index : Back to Suggestions & Feedback   RSS
Rick Rick

24 Aug 2011
Posts: 336

Every time I look at my Google Analytics Bounce Rate I wonder how much of that is me hitting my admin login page.

Should we hide the Analytics code when showing the admin login page? I'm thinking it shouldn't be hidden for all login pages, just maybe any that are admin only access. Eg admin/ (or equivelant) and sub pages.

Thoughts?
Jaijaz Jaijaz

24 Aug 2011
Posts: 215

To be honest I hadn't given it much thought before but if it is in fact contributing to bouce rate then it should definitely be removed for admin login.
If you not living on the edge you taking up too much space.
Rick Rick

25 Aug 2011
Posts: 336

I'm wondering about the best way to do this... eg do we just not show analytics code on "admin/" and subpages? (easy way).

Or do we choose which user groups (comma separated option or checkbox when editing groups) and use the permissions object to determine if pages are restricted to those groups, then hide the code? (robust way).

I'll dig into the permissions class and see what info it gives us beyond "canaccess".
Jaijaz Jaijaz

26 Aug 2011
Posts: 215

Thing is if you are looking at usergroup then they are already logged in to admin and analytics is turned off. I think the only thing that is needed is add a check for the admin/ uri in the analytics plugin.
If you not living on the edge you taking up too much space.
Rick Rick

26 Aug 2011
Posts: 336

I was meaning use the permissions object to see if the page was restricted to admins only. Would be able to check that without logging in. I'm happy to put it into the Analytics plugin like you said and revisit later if needed.
Jaijaz Jaijaz

26 Aug 2011
Posts: 215

Ah I get you now. Sorry on the wrong tangent.

I actually had an idea in the shower. A really simple way, would be to just put a flag on the page, don't include in analytics. The analytics plugin could add it on install. Saves messing with the permissions object.
If you not living on the edge you taking up too much space.
Rick Rick

26 Aug 2011
Posts: 336

Would that get messy? Eg all the plugins that add pages would need to consider this setting. You could default it to on then override it when showing admin pages but then it's half settings based and half automatic.
Jaijaz Jaijaz

26 Aug 2011
Posts: 215

My theory was that it would default to being turned off, ie unless other factors stopped it, it would run the analytics. The other factors currently being in the foot.tpl file:
{if $OPTIONS.analyticscode && !$isadmin && !$adminloggedin && $OPTIONS.analyticsposition != 'top'}

I think the simplest solution is to just add && $SITEURI != 'admin' to the end of it. However if we wanted to give the ability for other pages to opt out of being included in analytics the a check box on the page table could be used.

The issue I see is that the current way everything works is fine except that the admin uri, if not logged in as a admin usergroup member, runs the analytics code.
If you not living on the edge you taking up too much space.
Rick Rick

26 Aug 2011
Posts: 336

I'd prefer not to have to add check boxes to the page table if we could make it automatic instead.

For a start we could detect URLs that start with the _ADMINURI constant. Maybe with a preg match and Smarty assign in the analytics plugin api file.

I'm on the road at the moment, will look into it when I'm back on a computer.
Harvey

Core Developer

Harvey

26 Aug 2011
Posts: 327

In general, you always want analytics data to be collected. I can't think of any reason why you wouldn't want this - other than the issue of the site owner and webmaster clocking up unwanted hits.

If you had other reasons for wanting to hide analytics, then this should be added as a plugin (ie we should add a hook/filter to the code that includes the GA snippet and let plugin authors do what they like in their own plugin).

The 'no analytics for admins' system works perfectly so long as you stay logged in using the remember password option.

But if you login manually each time, then Rick has pointed out a small exception that you can't detect an admin user if they aren't logged in, so their hit will be recorded on the login page.

I can see 2 ways forward:
1. Remove the analytics from the login page. I don't really like this idea because firstly, people often login using a username/password form in the top-right of a template bypassing the login page completely, and secondly, the login page isn't just for admins - it's also used for forum users / affiliates / repeat shopping cart customers etc. In all these cases, you want the analytics code on the login page.

2. You set a "no_analytics" cookie whenever someone logs in as an admin, and use the cookie later on to block the analytics snippet. The cookie will work regardless of whether the user is logged in or not - so when they come back the analytics code won't show on the login page, but it will for everyone else.

Personally I think #2 is the way to go. The only complexity is that you need to use javascript to read the cookie, not PHP. Do not use PHP. Otherwise Jojo's internal caching is going to get in the way and you will get messed up stats. So use a javascript IF block to read the cookie and decide whether to include the analytics code or not.
Rick Rick

26 Aug 2011
Posts: 336

Good thinking on the caching. What do you think of check boxes on the user groups table? This lets us toggle analytics for any group, eg if someone adds a group for Editors instead of simple locking it to Admins and System Installers.
Back to Forum Index : Back to Suggestions & Feedback   RSS
You must be logged in to post a reply



You need to Register or Log In before posting on these forums.