-
Notifications
You must be signed in to change notification settings - Fork 31
Conversation
ga('send', 'pageview', path); | ||
} | ||
|
||
function sortQuery(query) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how to test this. @msecret would you mind just peeking at this function and let us know if it makes sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To test manually, you can build the JS with FEC_WEB_GOOGLE_ANALYTICS=true
and verify that the function is called--you can add a break point here, or open GA and watch the requests show up. Also would appreciate thoughts from @msecret.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Yeah, looks like it's working.
All makes sense to me. I just pinged Marco about taking a look at the |
@@ -222,6 +223,7 @@ ElectionLookup.prototype.search = function(e, opts) { | |||
self.serialized = serialized; | |||
if (opts.pushState) { | |||
window.history.pushState(serialized, null, URI('').query(serialized).toString()); | |||
analytics.pageView(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this get called if you search from the home page too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, but submitting the election search form on the home page triggers a new page load, which sends the event to GA.
I'm comfortable merging this, or we can wait for Marco to review. Fine either way. |
A thought that might merit some discussion: do we want to be able to track overall which filters on any given page are most used? Will this way of tracking things make it easy for us to find that data? |
That could be useful to know. This patch adds a page view for each filter URL, but I'm guessing it wouldn't be straightforward to extract views per filter from GA, since every combination of filters is a distinct view (i.e.,
But that doesn't seem right either--custom dimensions are sent along with regular page views, but we'd often want to send multiple values of the This might be simpler to solve by downloading data from GA or the API Umbrella analytics periodically and counting up filters with a custom script. But I'm feeling a little out of my depth here--might be useful to get feedback from the analytics guild. |
Right. That makes sense. I was thinking that simply downloading the data could work. I'm going to merge. |
Add virtual page views to Google Analytics. Sends page views on:
Also sorts query parameters so that /?cycle=2012&tab=disbursements is handled like /?tab=disbursements&cycle=2012.
See https://developers.google.com/analytics/devguides/collection/analyticsjs/single-page-applications for details.
cc @noahmanger