This plug-in is provided by Adobe Consulting as a courtesy to help you get more value out of Adobe Analytics. Adobe Customer Care does not provide support with this plug-in, including installation or troubleshooting. If you require help with this plug-in, contact your organization’s Adobe Account Team. They can arrange a meeting with a consultant for assistance.
The getTimeParting
plug-in allows you to capture the details of the time when any measurable activity takes place on your site. This plug-in is valuable when you want to breakdown metrics by any repeatable division of time over a given date range. For example, you can compare conversion rates between two different days of the week, such as all Sundays vs. all Thursdays. You can also compare periods of the day, such as all mornings vs. all evenings.
Analysis Workspace provides similar, out-of-the-box dimensions that are formatted slightly differently than this plug-in. See time parting dimensions in the Analyze user guide for more information. Some organizations find that Analysis Workspace’s out-of-the-box dimensions are sufficient.
Version 4.0+ of this plug-in is significantly different than earlier versions. Adobe highly recommends implementing this plug-in “from scratch”. Code referencing the plug-in before version 4.0 is not compatible with the current version of this plug-in.
Adobe offers an extension that allows you to use most commonly-used plug-ins with the Web SDK.
getTimeParting
Time Zone
parameter on the right.This plug-in is not yet supported for use within a manual implementation of the Web SDK.
Adobe offers an extension that allows you to use most commonly-used plug-ins with Adobe Analytics.
If you do not want to use the Common Analytics Plugins plug-in extension, you can use the custom code editor.
Copy and paste the following code anywhere in the AppMeasurement file after the Analytics tracking object is instantiated (using s_gi
). Preserving comments and version numbers of the code in your implementation helps Adobe with troubleshooting any potential issues.
/******************************************* BEGIN CODE TO DEPLOY *******************************************/
/* Adobe Consulting Plugin: getTimeParting v6.3 (No Prerequisites Needed) */
function getTimeParting(t){var c=t;if("-v"===t)return{plugin:"getTimeParting",version:"6.3"};a:{if("undefined"!==typeof window.s_c_il){var a=0;for(var b;a<window.s_c_il.length;a++)if(b=window.s_c_il[a],b._c&&"s_c"===b._c){a=b;break a}}a=void 0}"undefined"!==typeof a&&(a.contextData.getTimeParting="6.3");c=document.documentMode?void 0:c||"Etc/GMT";a=(new Date).toLocaleDateString("en-US",{timeZone:c,minute:"numeric",hour:"numeric",weekday:"long",day:"numeric",year:"numeric",month:"long"});a=/([a-zA-Z]+).*?([a-zA-Z]+).*?([0-9]+).*?([0-9]+)(.*?)([0-9])(.*)/.exec(a);return"year="+a[4]+" | month="+a[2]+" | date="+a[3]+" | day="+a[1]+" | time="+(a[6]+a[7])};
/******************************************** END CODE TO DEPLOY ********************************************/
The getTimeParting
function uses the following argument:
t
(Optional but recommended, string): The name of the time zone to convert the visitor’s local time to. Defaults to UTC/GMT time. See List of TZ database time zones on Wikipedia for a complete list of valid values.
Common valid values include:
"America/New_York"
for Eastern Time"America/Chicago"
for Central Time"America/Denver"
for Mountain Time"America/Los_Angeles"
for Pacific TimeCalling this function returns a string that contains the following delimited by a pipe (|
):
// Use the following code if the visitor resides in Paris, France
s.eVar8 = getTimeParting("Europe/Paris");
// Use the following code if the visitor resides in San Jose, California
s.eVar17 = getTimeParting("America/Los_Angeles");
// Use the following code if the visitor resides in Ghana.
// Note that Ghana is in GMT time, the default time zone that the plug-in uses with no argument
s.eVar22 = getTimeParting();
// Internet Explorer only returns the visitor's local time. Use this conditional statement to accommodate IE visitors
if(!document.documentMode) s.eVar39 = getTimeParting("America/New_York");
else s.eVarX = "Internet Explorer Visitors";
// Given a visitor from Denver Colorado visits a site on August 31, 2020 at 9:15 AM
// Returns the string value "year=2020 | month=August | date=31 | day=Friday | time=6:15 PM"
s.eVar10 = getTimeParting("Europe/Athens");
// Returns the string value "year=2020 | month=August | date=31 | day=Friday | time=6:15 AM"
s.eVar11 = getTimeParting("America/Nome");
// Returns the string value "year=2020 | month=August | date=31 | day=Friday | time=8:45 PM"
s.eVar12 = getTimeParting("Asia/Calcutta");
// Returns the string value "year=2020 | month=September | date=1 | day=Saturday | time=1:15 AM"
s.eVar13 = getTimeParting("Australia/Sydney");
tpDST
parameter, since daylight savings start/end dates are now detected automaticallyPrevious versions of this plug-in did not accommodate all years in the future. If you use a previous version of this plug-in, Adobe strongly recommends upgrading to the latest version to avoid JavaScript errors and data loss. If upgrading this plug-in is not feasible, make sure that the s._tpdst
variable in the plug-in code contains the appropriate years in the future.