kangguru / rack-google-analytics

Simple Rack middleware for implementing google analytics tracking in your Ruby-Rack based project. Supports synchronous and asynchronous insertion and configurable load options
MIT License
257 stars 53 forks source link

User-ID and Custom Dimensions? #44

Open grimmwerks opened 10 years ago

grimmwerks commented 10 years ago

They seem similar from a GA standpoint; but the attribution of User-ID was added to track users across devices. Google says to implement by

ga(‘set’, ‘&uid’, {{USER_ID}}); // Set the user ID using signed-in user_id.

Is this the same as setting custom dimensions and metrics, and how do we do that with rack-google-analytics?

In some cases, you might want to send a custom dimension or metric with all the hits on a given page (or for the lifetime of the tracker object). In this case, you can set the custom dimension or metrics using the set command:

ga('set', 'dimension5', 'custom data'); To set values for both a dimension and metric, you can use:

ga('set', { 'dimension5': 'custom dimension data', 'metric5': 'custom metric data' }); Read the Custom Dimensions and Metrics Section in the Field Reference document for the specific format of how to send this data.

grimmwerks commented 10 years ago

...and with the user_D send - this seems to be something done on everypage; unsure if there's a way to send it into the gem so that it too sends along on page views automatically?