gaAddons - Google Analytics Addons by Stéphane Hamel
Note: since GA offers the "Hour of the Day" Dimension by default, this call will be deprecated in futur releases of gaAddons.
Create a new session-level custom variable with the current hour of the day (24 hours basis, based on client local time). This is particularly useful for segmentation.
_setHourOfDay is initialized only on the 1st page view of the visit - therefore, if you want to use this feature, make sure it is included on every pages of your site.
The number of custom variables slots is limited to five. Be careful if you use this feature alongside other gaAddons features also making use of custom variables (namely, _4Q, _setDayOfWeek and _setHourOfDay).
_gaq.push(['_setHourOfDay', {
index: 2, // optional [1-5]
name: 'HourOfDay', // optional string
value: (new Date()).getHours(), // optional integer
scope: _GA_SCOPE_SESSION // optional _GA_SCOPE_PAGE|_GA_SCOPE_SESSION|_GA_SCOPE_VISITOR or use 3,2,1 respectively
}]);