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 Account Manager. 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.
If you do not want to use the 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.2 */
var getTimeParting=function(a){a=document.documentMode?void 0:a||"Etc/GMT";a=(new Date).toLocaleDateString("en-US",{timeZone:a, 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
method 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 method returns a string that contains the following delimited by a pipe (|
):
Use the following sample code if the client is in Paris, France:
s.eVarX = getTimeParting("Europe/Paris");
If the client is in San Jose, California:
s.eVarX = getTimeParting("America/Los_Angeles");
If the client is in the African country of Ghana:
s.eVarX = getTimeParting();
Ghana is within the UTC/GMT time zone. This example shows that no plug-in argument is necessary for UTC/GMT.
Use the following sample if you want to exclude time parting data from Internet Explorer Visitors. The value returned from IE browsers is only in the visitor’s local time.
if(!document.documentMode) s.eVarX = getTimeParting("America/New_York");
else s.eVarX = "Internet Explorer Visitors";
Consider an scenario where a visitor from Denver Colorado visits a site on August 31, 2020 at 9:15 AM.
s.eVar10 = getTimeParting("Europe/Athens");
// Returns the string value "year=2020 | month=August | date=31 | day=Friday | time=6:15 PM"
s.eVar11 = getTimeParting("America/Nome");
// Returns the string value "year=2020 | month=August | date=31 | day=Friday | time=6:15 AM"
s.eVar12 = getTimeParting("Asia/Calcutta");
// Returns the string value "year=2020 | month=August | date=31 | day=Friday | time=8:45 PM"
s.eVar13 = getTimeParting("Australia/Sydney");
// Returns the string value "year=2020 | month=September | date=1 | day=Saturday | time=1:15 AM"
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.