Configuring Google Analytics?
joefiorini opened this issue · comments
I'm curious how Yeoman has GA configured. I'm trying to set up insight for ember-cli
and I'm having trouble getting it to work.
At first I tried to create a mobile app property in GA; watching the real time view, I could see it record the hit when I ran my app, but it didn't show a name or any data for that matter.
So I created a second property as a web app. I updated the tracking code, and this time I couldn't get it to record a single hit.
In order to understand it better, I extracted the request into a separate script that I could run manually and get a feel for the API. Looking at the Universal API docs, it appears the an
& av
parameters are part of the Mobile App support. For mobile apps, names are recorded from the cd
parameter, with a type of appview
. So my working reuqest looked something like the following (removed some params for brevity):
{
v: 1,
t: 'appview',
an: 'ember-cli',
av: '0.0.16',
cd: 'ember build'
}
From the graphs, it looks like Yeoman is setup as a website property. How do you have it configured such that insight is able to track pageviews for you? Was I doing something wrong?
On further research, it appears pageview tracking works if I remove the an
& av
parameters.
I've forked insight already to make this work with our project (http://github.com/joefiorini/insight), I couldn't get it to work any other way. We're tracking with t: "appview"
instead of pageview
. Is this something insight should do by default?
@joefiorini insight was created before the Universal tracking API was public, so I don't think there was an appview back then. At least I didn't know about it. It might make sense to use appview
instead. I haven't looked into it. The pageview tracking support nested views with foo/bar
and let's you dig into either of them. Is this possible with appview?
Indeed one has to remove av
and an
for the realtime analytics to kick in. I'm curious, how do you use these two variables (along with pageview
) within GA?
Given the current approach, GA should be set up to use web tracking. av
and an
don't show up at all. Packages data (if that is your use case) has to be obtained by going down the ga:pagePathLevelX
tree.
For implementation you can see how we do it with bower: https://github.com/bower/stats.bower.io/blob/master/server/models/packages.coffee
Refactoring to use GA app tracking isn't as simple as renaming pageview
to appview
. GA's implementation is quite different between the 2 approaches. I would stick with Insight's defaults until we refactor to GA app tracking. I'll write more about how I think we should approach this later.
Docs are more complete now. Closing this in favor of discussing GA app-based tracking in a separate issue. Feel free to ping me if anyone has specific questions regarding GA set up.