I recently switched to Revo (last night) and I am having trouble finding a Google Analytics plugin. I refresh my pages so often when developing that I really need a plugin (like in Evo) that comments out the analytics code/tag when logged into the manager. Am I simply missing it or does it not exist?
I usually create a TV that I put in my templates
and in the TV I either place the GA code or a chunks that
has on it the GA code.
That way it is always in all the pages, without needing a plugin.
Website: www.mercologia.com
MODX Revo Tutorials: www.modxperience.com
MODX Professional Partner
Good idea, even though I think there is a parameter that can be used
in the GA code to not count the hits and clicks that come from your
IP/machine. I dont have that info handy, I will try to search for it
when I have time...
Website: www.mercologia.com
MODX Revo Tutorials: www.modxperience.com
MODX Professional Partner
This is PERFECT! Thank you SOOOOO much! Sorry I didn’t respond earlier, things are crazy, but thanks so much! Maybe you should submit this as a snippet to the Extras? I’m going to edit the snippet so a parameter, the account number, can be passed to the snippet and inserted into standard analytics code. No need for the chunk that way.
Actually, maybe I can alter the Evo plugin and bring it in line with Revo. It’s pretty simple and a good project to learn on... I’m proficient in ModX, just not coding plugins and snippets.
This single-line snippet should do it if your Manager username is admin (change the string if not):
<?php
return $modx->user->get('username') == 'admin' ? 'You are logged in.' : $modx->getChunk('GAnalytics') ;
It’s a little shorter and faster, and will still work if there are users logging in to the front end.
If you have multiple administrators, this should work:
<?php
return $modx->user->isMember('Administrator') ? 'You are logged in.' : $modx->getChunk('GAnalytics') ;
@BobRay:
As the way I see it, your solution are the most elegant and functional!
But it seems to be that it only works in the standard context (web) - if I am in a installation with multiply contexts (and logged in as at admin in the manager), it’s output the Analytics code - or are I’m missing something?
- A small step for mankind, so why not take two...
Working with web production, graphic design/workflow, photo and education - but are trying to get a life in between!
Quote from: Henrik at May 14, 2011, 01:55 PM
@BobRay:
As the way I see it, your solution are the most elegant and functional!
But it seems to be that it only works in the standard context (web) - if I am in a installation with multiply contexts (and logged in as at admin in the manager), it’s output the Analytics code - or are I’m missing something?
It should work in any context as long as your are either logged in in the front end as the admin or logged in in the Manager as the admin and previewing from there.
If you want to turn off GA when *anyone* is logged in to any context, you’d do this:
return $modx->user->hasSessionContext($modx->context->get('key')) ? 'You are logged in.' : $modx->getChunk('GAnalytics') ;
@BobRay: Thanks for your reply!
I don’t get it: I have a installation on Revo 2.10 RC 4 where there are 4 contexts - all are different domains.tld. All of them have the same context settings in the Access Permissions tab:
Usergroup: (anonymous) - Authority: 9999 - Access policy: Load only
Usergroup: Administrator - Authority: 0 - Access policy: Administrator
I have not messed with other permission settings, and I am the only with access to the manager.
But still the snippet only works on the default context (web), do you - or anybody else - have any clues on this?
- A small step for mankind, so why not take two...
Working with web production, graphic design/workflow, photo and education - but are trying to get a life in between!