Thanks for this thread. It was very useful. I got analytics going, and thought I would share my method. In the index.html, before the closing </head> tag, I added the Analytics code from the top of this Google Page
I wrapped the whole thing in an if statement:
if (document.domain === 'gis.nevcounty.net' )
so that the tracking only occurs once the app is deployed to our production web server.
We have a separate tracker code for our widget analytics, so I also added this line:
ga('create', 'XX-XXXXXX-X', 'auto',{'name': 'widgetTracker'});
widgetTracker is just a name that is assigend so that you can send page views or events to either tracker. Just use ga('send'.... for the first tracker, or ga('widgetTracker.send'..... for the second tracker.
So when the eSearch tool is opened, I log a pageview using the widgetTracker code, by adding this code to the beginning of the postCreate function:
if (ga){
ga('widgetTracker.send', 'pageview','MN_Widget/' + this.name);
}
The above will only log once when the widget is created, so it tells you that the tool was used during this session. I log specific events for various widget functions. So for instance if a user does a search using the eSearch tool, I added the following lines in Widget.js to the onSearch function that will track the type of search that they did:
if (ga){
var trackerLabelString = this.config.layers[this.AttributeLayerIndex].name
ga('widgetTracker.send', 'event', 'search', 'by Attribute: ' + trackerLabelString , {'nonInteraction': 1});
}
According to the documentation, the 'nonInteraction' object will send the event without impacting your bounce rate.