segment-boneyard / analytics-magento

[DEPRECATED] The hassle-free way to integrate analytics into any Magento store.
15 stars 19 forks source link

Enabled for admin users? #16

Closed ianstormtaylor closed 10 years ago

ianstormtaylor commented 10 years ago

From email:

Question for you about the !isAdmin() enabled condition: does that mean that the page is not an admin page? or that the user is not an admin user? The reason I ask is because that's the one setting from WordPress that might apply here. Basically it makes it so that while an admin is browsing around the site, their page views won't be counted and their "Viewed X Page" events won't be counted, since they would be artificially inflating their own stats. For big companies it never really matters, but for small or medium ones it often skews analytics data significantly. ("How many people visit the site five times a day? Woah 300! Oh wait half of that's the dev and marketing team >_< haha)

Does that setting make sense? I think the purest solution would be to just never track admin users, which we might opt to do. But one reason we've made it into a setting is that generally people install it, then navigate around see that events are working, and then disable admin tracking after that. There might be a nicer solution there though so let me know if you think of something.

astorm commented 10 years ago

Got is — the isAdmin check was checking admin page/context only — read on for why and a discussion of the problem.

Re: not tracking admin users when they're browsing — I definitely see the need for this but Magento's authentication model separates admin users and frontend cart users (the framework has a concept called "areas" which allow you to define different contexts — a frontend context, an admin context, etc) There's two separate sessions setup for each area/context. One named adminhtml, the other named frontend

screen shot 2014-07-14 at 1 16 31 pm

This means there's no easy way to know if a user is a logged in admin-user when they're browsing the store. We have two options here, each with a tradeoff. Let me know which one you think fits Segment's goals best.

First — I've previously done some experiments that allows Magento to temporarily switch session contexts, read some data from the alternate session, and then switch contexts back so everything works normally. I'd love the chance to try this code out in a real project but sessions are the sort of fiddly things that may require later bug fixes. I wouldn't be sure we could launch on day 1 without problems.

Second — lacking a way to read the admin context from a front-end context, the first solution that comes to mind is allowing system owners to blacklist certain IP addresses from their statistics. While not as elegant as automatically handling things, it would solve the problem, and also give those users a feeling of control. I'd see this as a simple text area where users could enter the IP addresses.

Let me know which direction you'd like to go, or if there's a third option you'd like to try.

ianstormtaylor commented 10 years ago

Gotcha, that makes perfect sense, thanks for the explanation. I think in that case let's just drop it completely. At some point we should probably have this kind of feature as a native Segment UI feature (either an IP blacklist list, or even just setting a cookie to blacklist people who visited the Segment UI since they'd be the admins). But that way we don't have to make it a Magento-specific concern.