dev.socrata.com icon indicating copy to clipboard operation
dev.socrata.com copied to clipboard

Add custom dimensions to Foundry pages

Open chrismetcalf opened this issue 10 years ago • 4 comments

So we can filter by domain and 4x4.

Requested by @marks

chrismetcalf avatar Jan 06 '16 01:01 chrismetcalf

Ick. Just realize the way that pageviews are being run asynchronously it'll be difficult to inject the custom dimensions. Gonna have to think about this one.

chrismetcalf avatar Jan 06 '16 02:01 chrismetcalf

@chrismetcalf not sure I understand the issue. The custom dimensions should be able to be added like this to https://github.com/socrata/labs-common/blob/master/js/lib/ga-tracking.js#L11

var regexMatches = /#\/(.*)\/([a-z0-9]{4}-[a-z0-9]{4})/.exec(location.hash)
vargaCustomDimensions = {}
gaCustomDimensions.dimension1 = regexMatches[1] /* datasetDomain */
gaCustomDimensions.dimension2 = regexMatches[2] /* datasetFourByFour */
ga('set', gaCustomDimensions)

marks avatar Jan 07 '16 15:01 marks

@marks Yeah, those need to be set before I call ga('send', 'pageview'), and that happens asynchronously and separately from where I parse out the domain and UID.

Totally doable, just need to figure out a way to do it that is clean.

chrismetcalf avatar Jan 07 '16 18:01 chrismetcalf

Right - I could be wrong but I think the solution is to just put them right before the send like this example: https://support.google.com/analytics/answer/2709828?hl=en#collection

marks avatar Jan 07 '16 19:01 marks