History

Refactor / fix page analytics

Thibaut committed 12 years ago

Commit 636fc8c1 parent a87dd251 file · +7 −4Browse files

Unified · Split

assets/javascripts/lib/page.coffee+7−4
@@ -41,8 +41,7 @@ page.show = (path, state) -> · 40 unmodified lines
4141 currentState = context.state
4242 page.dispatch(context)
4343 context.pushState()
44− ga?('send', 'pageview', location.pathname + location.search + location.hash)
45− _gauges?.push(['track'])
44+ track()
4645 context
4746
4847 page.replace = (path, state, skipDispatch, init) ->
@@ -51,8 +50,7 @@ page.replace = (path, state, skipDispatch, init) -> · 2 unmodified lines
5150 currentState = context.state
5251 page.dispatch(context) unless skipDispatch
5352 context.replaceState()
54− ga?('send', 'pageview', location.pathname + location.search + location.hash) unless init
55− _gauges?.push(['track'])
53+ track() unless init or skipDispatch
5654 context
5755
5856 page.dispatch = (context) ->
@@ -163,3 +161,8 @@ onclick = (event) -> · 104 unmodified lines
163161
164162 isSameOrigin = (url) ->
165163 url.indexOf("#{location.protocol}//#{location.hostname}") is 0
164+
165+track = ->
166+ ga?('send', 'pageview', location.pathname + location.search + location.hash)
167+ _gauges?.push(['track'])
168+ return