common analytics plugin extension v2.1€¦ · 3 | common analytics plugin extension v2.1.2...

165
1 | Common Analytics Plugin Extension v2.1.2 Common Analytics Plugin Extension V2.1.2 Contributors 2 Extension Overview 3 Adobe Consulting Plugin – apl (appendToList) 7 Adobe Consulting Plugin – addProductEvar 18 Adobe Consulting Plugin – addProductEvent 23 Adobe Consulting Plugin - cleanStr 30 Adobe Consulting Plugin – formatTime 34 Adobe Consulting Plugin – p_fo (pageFirstOnly) 41 Adobe Consulting Plugin – getAndPersistValue 45 Adobe Consulting Plugin – getTimeSinceLastVisit 50 Adobe Consulting Plugin – getGeoCoordinates 53 Adobe Consulting Plugin – getNewRepeat 57 Adobe Consulting Plugin – getPageLoadTime 63 Adobe Consulting Plugin – getPageName 68 Adobe Consulting Plugin – getPreviousValue 74 Adobe Consulting Plugin – getQueryParam 79 Adobe Consulting Plugin – getResponsiveLayout 87 Adobe Consulting Plugin – getTimeBetweenEvents 91 Adobe Consulting Plugin - getTimeParting 99 Adobe Consulting Plugin –getTimeToComplete 113 Adobe Consulting Plugin –getValOnce 118 Adobe Consulting Plugin – getVisitDuration 122 Adobe Consulting Plugin– getVisitNum 126

Upload: others

Post on 11-Oct-2020

12 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

1 | Common Analytics Plugin Extension v2.1.2

Common Analytics Plugin Extension V2.1.2 Contributors 2

Extension Overview 3

Adobe Consulting Plugin – apl (appendToList) 7

Adobe Consulting Plugin – addProductEvar 18

Adobe Consulting Plugin – addProductEvent 23

Adobe Consulting Plugin - cleanStr 30

Adobe Consulting Plugin – formatTime 34

Adobe Consulting Plugin – p_fo (pageFirstOnly) 41

Adobe Consulting Plugin – getAndPersistValue 45

Adobe Consulting Plugin – getTimeSinceLastVisit 50

Adobe Consulting Plugin – getGeoCoordinates 53

Adobe Consulting Plugin – getNewRepeat 57

Adobe Consulting Plugin – getPageLoadTime 63

Adobe Consulting Plugin – getPageName 68

Adobe Consulting Plugin – getPreviousValue 74

Adobe Consulting Plugin – getQueryParam 79

Adobe Consulting Plugin – getResponsiveLayout 87

Adobe Consulting Plugin – getTimeBetweenEvents 91

Adobe Consulting Plugin - getTimeParting 99

Adobe Consulting Plugin –getTimeToComplete 113

Adobe Consulting Plugin –getValOnce 118

Adobe Consulting Plugin – getVisitDuration 122

Adobe Consulting Plugin– getVisitNum 126

Page 2: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

2 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin – inList 132

Adobe Consulting Plugin – manageVars 137

Adobe Consulting Plugin – Numbers Suite 144

Adobe Consulting Plugin - pt 148

Adobe Consulting Plugin - removeFromList 152

Adobe Consulting Plugin – getDaysSinceLastVisit – (Deprecated) 163

Contributors VERSION AUTHOR SUMMARY OF CHANGES

1.0.4 Stephen Pelhan & Greg Clausen

Initial version containing seven plugins

2.0.2 Greg Clausen & Ritesh Gupta

Added remaining plugins. Changed the method to initialize the plugins

2.1.0 Stephen Pelhan Greg Clausen Ritesh Gupta

Added six new plugins to the extension (addProductEvar, addProductEvent, getGeoCoordinates, getResponsiveLayout, getTimeSinceLast Visit, Numbers Suite) Updated eight plugins (apl, getNewRepeat, pagePageName, getQueryParam, getTimeToComplete, inList, ManageVars, getTimeParting) Added logic to throw an exception if the Adobe Analytics extension is not installed in the web property

2.1.1 Stephen Pelhan Greg Clausen Ritesh Gupta

Updated documentation Added getDaysSinceLastVisit(deprecated) to ensure backwards compatibility

2.1.2 Stephen Pelhan Greg Clausen Ritesh Gupta

Updated getTimeParting plugin code for compatibility issues

Page 3: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

3 | Common Analytics Plugin Extension v2.1.2

Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version of the initially launched v1.0.4. This extension allows integration of a common list of all the Adobe Consulting sponsored plugins in Adobe Launch. There is also a shift in the way to initialize these plugins.

Instead of initializing individual plugins in your Launch property, you just select the Common Analytics plugin Extension in Action Type, and you are served an option to pick and choose the plugins you’d like to integrate. Your library loads the code only for those selected plugins.

Page 4: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

4 | Common Analytics Plugin Extension v2.1.2

A list of plugins available for integration with the v2.1.1 extension

Plugin Name Function name Version Description

Append to List apl 3.2 Add new values to list-delimited variables (e.g. events, linkTrackVars, listVars, etc.). This plugin requires "inList" to be initialized as well

Add Product eVar

addProductEvar 1.0 Easily add an Adobe Analytics merchandising eVar that uses product syntax to the products variable (s.products) without worrying whether the already-existing contents of the variable will be changed/moved/deleted.

Add Product event

addProductEvent 1.0 Easily add an Adobe Analytics custom numeric event or custom currency event to the products variable (s.products) without worrying whether the already-existing contents of the variable will be changed/moved/deleted.

Clean String cleanStr 1.0 Remove unnecessary characters from a string (or string variable), including HTML tag characters, Extra whitespaces (including double spaces), Left/right single quotes (‘’) (replaced with straight single quotes), Tabs, Newlines/Carriage Returns

Format Time formatTime 1.1 Take a specified number of seconds and present them in a bucketed format, rounded to a benchmark value that you specify. The "inList" plugin is required by this plugin. This plugin requires "inList" to be initialized as well

First Page Only p_fo 2.0 Checks for the existence of a specific JavaScript object. If the object doesn't exist, the plugin creates the object and returns the value of true. This would be the first and only time the plugin would create this object on the current page (hence the name, pageFirstOnly). If the JavaScript object already exists on the page, the function will return the value of false

Persist Value getAndPersistValue 2.0 Stores a value in a cookie that can be retrieved later during a visit

Time Since Last Visit

getTimeSinceLastVisit 1.0 Returns the time since the visitor’s last (most recent) visit

Geographic Coordinates

getGeoCoordinates 1.0 Returns the geographic location (latitude and longitude) of the visitor’s device

New Repeat Visitor

getNewRepeat 2.1 Determines whether a visitor to the site is a new visitor or a repeat visitor within the number of days that is specified in the plugin call

Page 5: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

5 | Common Analytics Plugin Extension v2.1.2

Page Load Time getPageLoadTime 1.0 Uses the JavaScript performance object to allow you to measure the amount of time. Page takes to load completely. The plugin requires “p_fo” to be initialized as well

Page Name getPageName 4.1 Creates a value that can be inserted into the Adobe Analytics pageName variable and that is an easy-to-read, “friendly”-formatted version of the current URL

Previous Value getPreviousValue 2.0 Set an Analytics variable equal to the value of a variable that was set on a previous page or contained in a previous image request. The plugin requires “p_fo” to be initialized as well

Query Param getQueryParam 3.3 Case-insensitively extract the value of any query string parameter contained in a URL. This plugin requires "pt" to be initialized as well

Responsive Layout

getResponsiveLayout 1.0 Which version of your responsive design-based website a visitor is currently looking at

Time Between Events

getTimeBetweenEvents 2.1 Amount of time between two different Adobe Analytics events (custom or otherwise). This plugin requires "inList" to be initialized as well

Time Parting getTimeParting 6.1 Capture the details of the time when any measurable activity takes place on its site

Time to Complete

getTimetoComplete 3.1 Time a user takes to complete a process on a site. The "clock" begins when the "start" action is called and ends when the "stop" action is called. This plugin requires "pt" to be initialized as well

Value Once getValOnce 2.0 Prevents a variable from being set equal to the same value on consecutive calls

Visit Duration getVisitDuration 2.0 Amount of time (in minutes) that the visitor has been on the site up to that point

Visit Number getVisitNum 4.1 Visit number for all visitors that come to the site within a specific time period (e.g. "x" number of days)

In List inList 2.1 Check whether a value already exists within either a delimited list of values or a JavaScript array object

Manage Variables

manageVars 2.1 Manipulate the values of multiple Adobe Analytics variables at one time; this version includes specific functionality to lowercase or remove unnecessary characters from multiple variable values at the same time. This plugin requires "pt" & "cleanStr" to be initialized as well

Numbers Suite 1.0 • A number of zeroes to the beginning of a number

Page 6: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

6 | Common Analytics Plugin Extension v2.1.2

• Generate a random number with a specific number of digits

• Round a number to the closest hundreth (for currency)

pt pt 2.0 Executes a function on a list of Adobe Analytics

variables. For example, the following function will run the clearVars function three times, once using eVar1 as the argument, once using eVar4 as the argument, and once using eVar29 as the argument. The end result clear out the values of eVar1, eVar4 & eVar29. s.pt('eVar1,eVar4,eVar29', ',', 'clearVars')

Remove from List

rfl 2.0 Remove values from list-delimited variables (e.g. s.events, s.linkTrackVars, listVars, etc.)

Days Since Last Visit

getDaysSinceLastVisit 3.0 Returns the number of days since the visitor’s last (most recent) visit - Deprecated

Page 7: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

7 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin – apl (appendToList)

General Details

Plugin Name: apl (appendToList) Latest Version: 3.1 Latest Version Save Date: 2018-04-16

Purpose of This Plugin

What does this plugin do? The apl (appendToList) plugin allows you to "safely" add new values to list-delimited variables (e.g. events, linkTrackVars, listVars, etc.).

Why should I use this plugin? You should use the apl plugin if you want to add a new value to an already-existing, list-delimited variable

• If the value you want to add already exists in the list-delimited variable, then the code will not add another instance of the value to the end of the variable.

• If the value you want to add doesn't already exist in the variable, then the code will add the value to the end of the variable.

• If the list-delimited variable that you want to add the new value to hasn't been set yet (i.e. the variable is null/undefined/blank), then the code will simply set the variable equal to the new value

Using the apl plugin will help prevent potential duplicate values from being added to a list. For example, assume…

s.events = "event1,event2";

If you use apl to try and add event1 to s.events, the logic would not add it due to the fact that s.events already contains "event1".

Page 8: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

8 | Common Analytics Plugin Extension v2.1.2

Why shouldn't I use this plugin? If you don't care whether a new value you want to add already exists in a list-delimited variable, then you have no need for this plugin and can use a simple concatenation operator instead.

For example…

s.events = s.events + ",event1";

…will do a perfectly fine job of adding event1 to the end of s.events regardless of whether event1 already exists in s.events.

Prerequisites You must have AppMeasurement (i.e. the base Adobe Analytics Code) and the inList v2.0 plugin (included in the Code to Deploy section below) to run the apl plugin

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code

NOTE: Adding the cyan-highlighted comments/version numbers of the code to the AppMeasurement file will help Adobe Consulting with troubleshooting any potential implementation issues.

Run the apl plugin as needed within the doPlugins function (see example calls below)

Page 9: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

9 | Common Analytics Plugin Extension v2.1.2

Arguments to Pass In lv ("sort-of" required, string): A JavaScript variable that contains a delimited list of items to add a new value to

vta (required, string): A comma delimited list of the new value(s) to add to the lv argument's value.

d1 (optional, string): The delimiter used to separate out the individual values already contained in the lv argument. Defaults to a comma (i.e. ",") when not set

d2 (optional, string): The delimiter that the plugin will use to join the values in the final list to be returned. Defaults to the same value as d1 (i.e. a comma or otherwise) when not set

cc (optional, boolean): A flag that says whether a case-sensitive check will be used to determine whether the vta argument value already exists in the lvta argument value, defaults to false

• If cc equals true, then a case-sensitive check will be made between the new value(s) you want to add (i.e. the vta argument) and each value contained in the lv argument

• If cc is not set (or is not set equal to true), then a case-insensitive check will be made between the new value(s) you want to add (i.e. the vta argument) and each value contained in the lv argument

Returns The apl plugin returns the value of the lv argument, plus any additional values (specified in the vta argument) that weren't previously contained in the lv argument's original value.

Cookies The apl plugin does not set any cookies

Page 10: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

10 | Common Analytics Plugin Extension v2.1.2

Example Calls

Example #1

If…

s.events = "event22,event24";

…and the following code runs…

s.events = s.apl(s.events, "event23");

… the final value of s.events will be:

s.events = "event22,event24,event23";

Example #2

If…

s.events = "event22,event23";

…and the following code runs…

s.events = s.apl(s.events, "event23");

… the final value of s.events will still be:

s.events = "event22,event23";

In this example, the apl call made no changes to s.events since s.events already contained "event23"

Page 11: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

11 | Common Analytics Plugin Extension v2.1.2

Example #3

If…

s.events = ""; //blank value

…and the following code runs…

s.events = s.apl(s.events, "event23");

… the final value of s.events will be…

s.events = "event23";

Example #4

If…

s.prop4 = "hello|people";

…and the following code runs…

s.eVar5 = s.apl(s.prop4, "today", "|");

… the final value of s.prop4 will still be…

s.prop4 = "hello|people";

…but the final value of s.eVar5 will be

s.eVar5 = "hello|people|today";

Keep in mind that the plugin only returns a value; it does not necessarily "reset" the variable passed in through the lv argument.

Page 12: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

12 | Common Analytics Plugin Extension v2.1.2

Example #5

If…

s.prop4 = "hello|people";

…and the following code runs…

s.prop4 = s.apl(s.prop4, "today");

… the final value of s.prop4 will be…

s.prop4 = "hello|people,today";

Be sure to keep the delimiter consistent between what's in the lv argument's value and what's in the d1/d2 arguments

Example #6

If…

s.events = "event22,event23";

…and the following code runs…

s.events = s.apl(s.events,"EVenT23", ",", ",", true);

… the final value of s.events will be:

s.events = "event22,event23,EVentT23";

Although this example isn't practical, it demonstrates the need to use caution when using the case sensitive flag.

Page 13: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

13 | Common Analytics Plugin Extension v2.1.2

Example #7

If…

s.events = "event22,event23";

…and the following code runs…

s.events = s.apl(s.events, "event23,event24,event25");

… the final value of s.events will be:

s.events = "event22,event23,event24,event25");

The plugin will not add "event23" to s.events because it already exists in s.events. However, it will add both event24 and event25 to s.events because neither were previously contained in s.events.

Example #8

If…

s.linkTrackVars = "events,eVar1";

…and the following code runs…

s.linkTrackVars = s.apl(s.linkTrackVars, "campaign", ",", ",", false);

… the final value of s.linkTrackVars will be:

s.linkTrackVars = "events,eVar1,campaign";

The last three arguments (i.e. ",", ",", false) at the end of this apl call are not necessary but are also not "hurting anything" by being there since they match the default argument values.

Page 14: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

14 | Common Analytics Plugin Extension v2.1.2

Example #9

If…

s.events = "event22,event24";

…and the following code runs…

s.apl(s.events, "event23");

… the final value of s.events will still be:

s.events = "event22,event24";

Running the plugin all by itself (without assigning the return value to a variable) does not actually "reset" the variable passed in through the lv argument.

Example #10

If…

s.list2 = "casesensitivevalue|casesensitiveValue"

…and the following code runs…

s.list2 = s.apl(s.list2, "CasESensiTiveValuE", "|", "-", true);

… the final value of s.list2 will be:

s.list2 = "casesensitivevalue-casesensitiveValue-CasESensiTiveValuE"

Since the two delimiter arguments are different, the value passed in will be delimited by a different character than the return value

Page 15: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

15 | Common Analytics Plugin Extension v2.1.2

S Object Replacement

When instantiating the main AppMeasurement library object with a name other than "s", change the following portion of the plugin code from this…

s.apl=function(lv,vta,d1,d2,cc)

…to this:

[objectname].apl=function(lv,vta,d1,d2,cc)

Be sure to also change the inList plugin from this…

s.inList=function(lv,vtc,d,cc)

…to this:

[objectname].inList=function(lv,vtc,d,cc)

Upgrading from Previous Versions If you want to continue using the older name of the plugin ("apl"), you may also change the beginning part of the code to this…

s.apl=function(lv,vta,d1,d2,cc)

…or this:

[objectname].apl=function(lv,vta,d1,d2,cc)

etc.

Page 16: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

16 | Common Analytics Plugin Extension v2.1.2

Version History

3.1 (2018-04-22)

• d2 argument now defaults to the value of the d1 argument when not set

3.0 (2018-04-16)

• Complete reanalysis/rewrite of plugin • Added advanced error checking, updated documentation with required vs. optional arguments • The value to add (vta) argument now accepts multiple values at one time • Added the d2 argument to format the return value • Changed the cc argument to a boolean

2.5 (2016-02-18)

• Now uses the inList plugin utility for its comparison processing

2.0 (2016-01-26)

• d (Delimiter) argument now optional (defaults to a comma) • u (Case-sensitivity flag) argument now optional (defaults to case-insensitive) • Regardless of the u (Case-sensivity flag) argument setting, the apl plugin will no longer append a

value to a list if the value already exists in the list (see the "Why shouldn't I use this plugin?" section above)

Return to Table of Contents

Page 17: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

17 | Common Analytics Plugin Extension v2.1.2

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: apl (appendToList) v3.1 (requires AppMeasurement and inList v2.0) */ s.apl=function(lv,vta,d1,d2,cc){d1=d1?d1:",";d2=d2?d2:d1;if("undefined"===typeof this.inList)return console.log("Adobe Analytics: Problem with apl plugin - inList plugin not available"),lv;if("undefined"!==typeof lv&&"string"!==typeof lv)return console.log("Adobe Analytics: Problem with apl plugin - first passed-in argument is not a string object"),"";if("string"!==typeof vta)return lv;vta=vta.split(",");for(var g=vta.length,d=0;d<g;d++)this.inList(lv,vta[d],d1,cc)||(lv=lv?lv+d2+vta[d]:vta[d]);return lv}; /* Adobe Consulting Plugin: inList v2.0 (Requires AppMeasurement) */ s.inList=function(lv,vtc,d,cc){if("string"!==typeof vtc)return!1;if("string"===typeof lv)lv=lv.split(d?d:",");else if("object" !==typeof lv)return!1;d=0;for(var e=lv.length;d<e;d++)if(cc&&vtc===lv[d]||!cc&&vtc.toLowerCase()===lv[d].toLowerCase()) return!0;return!1}; /******************************************** END CODE TO DEPLOY ********************************************/

Page 18: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

18 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin – addProductEvar

General Details

Plugin Name: addProductEvar Latest Version: v1.0 Latest Version Save Date: 2019-10-07

Purpose of This Plugin

What does this plugin do? The addProductEvar plugin allows you to easily add an Adobe Analytics merchandising eVar that uses product syntax to the products variable without worrying whether the already-existing contents of the products variable will be changed/moved/deleted.

Why should I use this plugin? You should use the addProductEvar plugin if you want to add a merchandising eVar that uses product syntax to the Adobe Analytics products variable

Why shouldn't I use this plugin? You won't need to use the addProductEvar plugin if you don't use merchandising eVars with product syntax or you don't use Adobe Analytics

Prerequisites You must have AppMeasurement (i.e. the base Adobe Analytics Code) to run the addProductEvar plugin

Page 19: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

19 | Common Analytics Plugin Extension v2.1.2

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code to the AppMeasurement file will help Adobe Consulting with troubleshooting any potential implementation issues.

• Run the addProductEvar function as needed within the doPlugins function (see example calls below)

Arguments to Pass In en (required, string) - the eVar to add to the last entry currently contained in the products variable. If the products variable is blank, then a "blank" product entry will be created with the eVar value attached to the end of the value

ev (required, string) - the value to be assigned to the eVar

ap (optional, boolean) - If the products variable currently contains more than one product entry, a value of true (or 1) will add the eVar to all the product entries. Defaults to false (or 0), which will add the eVar to only the last entry contained in the products variable

Returns The addProductEvar plugin returns nothing but adds the eVar (and eVar value) specified in the en argument/ev argument to the Adobe Analytics products variable

Cookies The addProductEvar plugin does not create or use any cookies

Page 20: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

20 | Common Analytics Plugin Extension v2.1.2

Example Calls

Example #1

If…

s.products=";product1;3;300,;product2;2;122,;product3;1;25"

…and the following code runs…

s.addProductEvar("eVar25", "blue");

… the final value of s.products will be:

s.products=";product1;3;300,;product2;2;122,;product3;1;25;;eVar25=blue"

Example #2

If…

s.products=";product1;3;300,;product2;2;122,;product3;1;25"

…and the following code runs…

s.addProductEvar("eVar25", "blue", 1);

… the final value of s.products will be:

s.products=";product1;3;300;;eVar25=blue,;product2;2;122;;eVar25=blue,;product3;1;25;;eVar25=blue"

When the third argument is equal to true (or 1), each product entry will have the eVar specified in the call added to its value

Page 21: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

21 | Common Analytics Plugin Extension v2.1.2

Example #3

If…

s.products=";product1;3;300;event2=10;eVar23=large|eVar24=men|eVar25=blue,;product2;2;122,;product3;1;25"

…and the following code runs…

s.addProductEvar("eVar23", "medium"); s.addProductEvar("eVar24", "women"); s.addProductEvar("eVar25", "red");

… the final value of s.products will be:

s.products=";product1;3;300;event2=10;eVar23=large|eVar24=men|eVar25=blue,;product2;2;122,;product3;1;25;;eVar23= medium|eVar24=women|eVar25=red"

Example #4

If…

s.products=";product1;3;300;event2=10;eVar23=large|eVar24=men|eVar25=blue,;product2;2;122,;product3;1;25"

…and the following code runs…

s.addProductEvar("eVar23", "medium", 1); s.addProductEvar("eVar24", "women", 1); s.addProductEvar("eVar25", "red", 1);

… the final value of s.products will be:

s.products=";product1;3;300;event2=10;eVar23=large|eVar24=men|eVar25=blue|eVar23=medium|eVar24=women|eVar25=red, ;product2;2;122;;eVar23=medium|eVar24=women|eVar25=red,;product3;1;25;;eVar23=medium|eVar24=women|eVar25=red"

The addProductEvar plugin does not replace eVars that are already set within an individual product entry; it merely appends the values that you specify in the calls. Hence, use caution when using the plugin so that product entries that already have eVar values bound to them do not have additional duplicate/unnecessary values bound as well.

Page 22: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

22 | Common Analytics Plugin Extension v2.1.2

Example #5

If s.products isn't set and the following code runs…

s.addProductEvar("eVar25", "blue");

… the final value of s.products will be:

s.products=";;;;;eVar25=blue"

S Object Replacement

When instantiating the main AppMeasurement library object with a name other than "s", change the following portion of the plugin code from this…

s.addProductEvar=function(en,ev,ap)

…to this:

[objectname].addProductEvar=function(en,ev,ap)

Version History

1.0 (2019-10-07)

• Initial Release

Return to Table of Contents

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: addProductEvar v1.0 (Requires AppMeasurement) */ s.addProductEvar=function(en,ev,ap){if("string"===typeof en&&"string"===typeof ev&&""!==ev)if(ap=ap||!1,this.products){var e=this.products.split(","),f=e.length;ap=ap?0:f-1;for(var a;ap<f;ap++)a=e[ap].split(";"),a[5]&&-1<a[5].toLowerCase().indexOf("evar")? a[5]=a[5]+"|"+en+"="+ev:a[5]?a[5]=en+"="+ev:a[5]||(a[4]||(a[4]=""),a[3]||(a[3]=""),a[2]||(a[2]=""),a[1]||(a[1]=""),a[5]=en+"="+ev),e[ap]=a.join(";");this.products=e.join(",")}else this.products=";;;;;"+en+"="+ev}; /******************************************** END CODE TO DEPLOY ********************************************/

Page 23: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

23 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin – addProductEvent

General Details

Plugin Name: addProductEvent Latest Version: v1.0 Latest Version Save Date: 2019-10-07

Purpose of This Plugin

What does this plugin do? The addProductEvent plugin allows you to easily add an Adobe Analytics custom numeric event or custom currency event to the products variable without worrying whether the already-existing contents of the products variable will be changed/moved/deleted.

Why should I use this plugin? You should use the addProductEvent plugin if you want to add a custom numeric event or custom currency event to the Adobe Analytics products variable

Why shouldn't I use this plugin? You won't need to use the addProductEvent plugin if you don't need to set a custom numeric event or custom currency event within the products variable. Using the plugin won't be necessary also if you use only custom counter events or you don't use Adobe Analytics in general

Prerequisites You must have AppMeasurement (i.e. the base Adobe Analytics Code) and the apl/inList plugins to run the addProductEvent plugin

Page 24: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

24 | Common Analytics Plugin Extension v2.1.2

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code to the AppMeasurement file will help Adobe Consulting with troubleshooting any potential implementation issues.

• Run the addProductEvent function as needed within the doPlugins function (see example calls below)

Arguments to Pass In en (required, string) - the event to add to the last entry currently contained in the products variable. If the products variable is blank, then a "blank" product entry will be created with the event (and its value) attached to the end.

ev (required, number) - the value to be assigned to the custom numeric/currency event specified in the en argument. Defaults to 1 when not set or I fh

ap (optional, boolean) - If the products variable currently contains more than one product entry, a value of true (or 1) will add the event to all the product entries. Defaults to false (or 0), which will add the event (and its value) to only the last entry contained in the products variable

Returns The addProductEvent plugin returns nothing but adds the event (and its value) as specified in the en argument/ev argument to the Adobe Analytics products variable. The plugin will also automatically add the event to the s.events variable since all events that are set in the products variable need to be set also in the events variable.

Cookies The addProductEvent plugin does not create or use any cookies

Page 25: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

25 | Common Analytics Plugin Extension v2.1.2

Example Calls

Example #1

If…

s.products=";product1;3;300,;product2;2;122,;product3;1;25" s.events="purchase"

…and the following code runs…

s.addProductEvent("event35", "25");

… the final value of s.products will be…

s.products=";product1;3;300,;product2;2;122,;product3;1;25;event35=25"

…and the final value of s.events will be:

s.events="purchase,event35"

Example #2

If…

s.products=";product1;3;300,;product2;2;122,;product3;1;25"

…and the following code runs…

s.addProductEvent("event35", 25, 1);

… the final value of s.products will be:

s.products=";product1;3;300;event35=25,;product2;2;122;event35=25,;product3;1;25;event35=25"

When the third argument is equal to true (or 1), each product entry will have the event specified in the call added to its value

Page 26: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

26 | Common Analytics Plugin Extension v2.1.2

Example #3

If…

s.products=";product1;3;300;event2=10;eVar33=large|eVar34=men|eVar35=blue,;product2;2;122,;product3;1;25" s.events="purchase,event2"

…and the following code runs…

s.addProductEvent("event33", "12"); s.addProductEvent("event34", "10"); s.addProductEvent("event35", "15");

… the final value of s.products will be…

s.products=";product1;3;300;event2=10;eVar33=large|eVar34=men|eVar35=blue,;product2;2;122,;product3;1;25;event33= 12|event34=10|event35=15"

…and s.events will be:

s.events="purchase,event2,event33,event34,event35"

Page 27: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

27 | Common Analytics Plugin Extension v2.1.2

Example #4

If…

s.products=";product1;3;300;event2=10;eVar33=large|eVar34=men|eVar35=blue,;product2;2;122,;product3;1;25" s.events="purchase,event2"

…and the following code runs…

s.addProductEvent("event33", "12", 1); s.addProductEvent("event34", 10, 1); //The second argument can be an integer or a string representing an integer/number s.addProductEvent("event35", "15", 1);

… the final value of s.products will be…

s.products=";product1;3;300;event2=10|event33=12|event34=10|event35=15;eVar33=large|eVar34=men|eVar35=blue, ;product2;2;122;event33=12|event34=10|event35=15,;product3;1;25;event33=12|event34=10|event35=15"

…and s.events will be:

s.events="purchase,event2,event33,event34,event35"

Example #5

If s.products isn't set and the following code runs…

s.addProductEvent("event35", "25");

… the final value of s.products will be:

s.products=";;;;event35=25"

In this case, event35 will also be appended to the end of s.events

Page 28: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

28 | Common Analytics Plugin Extension v2.1.2

S Object Replacement

When instantiating the main AppMeasurement library object with a name other than "s", change the following portion of the plugin code from this…

s.addProductEvent=function(en,ev,ap)

…to this:

[objectname].addProductEvent=function(en,ev,ap)

Also be sure to change this…

s.apl=function(lv,vta,d1,d2,cc){

…to this:

[objectname].apl=function(lv,vta,d1,d2,cc){

And change this…

s.inList=function(lv,vtc,d,cc){

…to this:

[objectname].inList=function(lv,vtc,d,cc){

Version History

1.0 (2019-10-07)

• Initial Release

Return to Table of Contents

Page 29: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

29 | Common Analytics Plugin Extension v2.1.2

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: addProductEvent v1.0 (Requires AppMeasurement and the apl v3.1+/inList v2.0+ plugins) */ s.addProductEvent=function(en,ev,ap){var s=this;if("string"===typeof en)if(ev=isNaN(ev)?"1":String(ev),ap=ap||!1,s.events= s.apl(s.events,en),s.products){var e=s.products.split(",");ap=ap?0:e.length-1;for(var a;ap<e.length;ap++)a=e[ap].split(";") ,a[4]&&a[4].includes("event")?a[4]=a[4]+"|"+en+"="+ev:a[5]?a[4]=en+"="+ev:a[4]||(a[3]||(a[3]=""),a[2]||(a[2]=""),a[1]||(a[1]=""),a[4]=en+"="+ev),e[ap]=a.join(";");s.products=e.join(",")}else s.products=";;;;"+en+"="+ev}; /* Adobe Consulting Plugin: apl (appendToList) v3.2 (Requires AppMeasurement and inList v2.0 or higher) */ s.apl=function(lv,vta,d1,d2,cc){if(!lv||"string"===typeof lv){if("undefined"===typeof this.inList||"string"!==typeof vta||""===vta)return lv;d1=d1||",";d2=d2||d1;1==d2&&(d2=d1,cc||(cc=1));2==d2&&1!=cc&&(d2=d1);vta=vta.split(",");for(var g=vta.length,e=0;e<g;e++)this.inList(lv,vta[e],d1,cc)||(lv=lv?lv+d2+vta[e]:vta[e])}return lv}; /* Adobe Consulting Plugin: inList v2.1 (Requires AppMeasurement) */ s.inList=function(lv,vtc,d,cc){if("string"!==typeof vtc)return!1;if("string"===typeof lv)lv=lv.split(d||",");else if("object"!== typeof lv)return!1;d=0;for(var e=lv.length;d<e;d++)if(1==cc&&vtc===lv[d]||vtc.toLowerCase()===lv[d].toLowerCase())return!0;return!1}; /******************************************** END CODE TO DEPLOY ********************************************/

Page 30: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

30 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin - cleanStr

General Details

Plugin Name: cleanStr Latest Version: 1.0 Latest Version Save Date: 2018-04-13

Purpose

What does this plugin do? The cleanStr plugin removes/replace all unnecessary characters from a string (or string variable), including the following characters:

• HTML tag characters

• Extra whitespaces (including double spaces)

• Left/right single quotes (‘’) (replaced with straight single quotes)

• Tabs

• Newlines/Carriage Returns

Why should I use this plugin? You should use the cleanStr plugin if you want to remove any unnecessary characters from your Adobe Analytics variables (or any variables, for that matter)

Why shouldn't I use this plugin? If all of the data you collect in your variables contain no unnecessary characters, then you won't need to use the cleanStr plugin

Page 31: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

31 | Common Analytics Plugin Extension v2.1.2

Prerequisites None

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code to your AppMeasurement file will help Adobe Consulting with troubleshooting any potential issues with your implementation.

Run the cleanStr plugin whenever necessary (see example calls below)

Arguments to Pass In str (required, string): A string (variable or otherwise) containing any HTML encoding, extra whitespace, tabs, etc. that you want to remove from its value

Returns The cleanStr plugin returns the value of the str argument but with all of the unnecessary characters taken out

Cookies The cleanStr plugin does not create any cookies

Page 32: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

32 | Common Analytics Plugin Extension v2.1.2

Example Calls

Example #1 Assume the following (where the dots represent spaces and the arrows represent tab characters

When you run the following code…

s.eVar1 = cleanStr(s.eVar1)

…eVar1 will be set equal to "this is a messystring" (with all extra spaces and all tab characters removed)

Example #2 If…

…and the following code runs…

cleanStr(s.eVar1)

… the final value of s.eVar1 will still be:

Running the plugin all by itself (without assigning the return value to a variable) does not actually "reset" the variable passed in through the str argument.

S Object Replacement The cleanStr plugin does not require AppMeasurement or any other plugins and thus does not need to be attached to the s object (or other AppMeasurement object)

Page 33: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

33 | Common Analytics Plugin Extension v2.1.2

Version History

1.0(2018-04-15)

• Point Release (recompiled, smaller code size) and first official release

Return to Table of Contents

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: cleanStr v1.0 (No Prerequisites Required) */ var cleanStr=function(str){if("string"===typeof str){str=str.replace(/<\/?[^>]+(>|$)/g,"");str=str.replace(/^\s+|\s+$/g, "");str=str.replace(/[\u2018\u2019\u201A]/g,"'");str=str.replace(/\t+/g,"");for(str=str.replace(/[\n\r]/g," ");-1<str.indexOf(" ");)str=str.replace(/\s\s/g," ");return str}return""}; /******************************************** END CODE TO DEPLOY ********************************************/

Page 34: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

34 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin – formatTime

General Details

Plugin Name: formatTime Latest Version: v1.1 Latest Version Save Date: 2018-05-21

Purpose of This Plugin

What does this plugin do? The formatTime plugin allows you to take a specified number of seconds and present them in a bucketed format, rounded to a benchmark value that you specify

Why should I use this plugin? You should use the formatTime plugin if you want to capture a value in seconds and convert it into a more rounded format (i.e. minutes, hours, days, etc.)

Why shouldn't I use this plugin? You won't need to use the formatTime plugin if you don't need to capture any second-based values or convert those values into a more rounded format

Prerequisites You must have AppMeasurement (i.e. the base Adobe Analytics Code) and the inList Plugin (included in the Code to Deploy section below) to run the formatTime plugin

Page 35: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

35 | Common Analytics Plugin Extension v2.1.2

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code

NOTE: Adding the cyan-highlighted comments/version numbers of the code to the AppMeasurement file will help Adobe Consulting with troubleshooting any potential implementation issues.

Run the formatTime function as needed within the doPlugins function (see example calls below)

Arguments to Pass In ns(required, integer): The number of seconds to convert/format

tf(optional, string): The type of format to return the seconds in; defaults to seconds

• Set equal to "d" if you want the time to be formatted into days (rounded to the closest 1/4 day benchmark by default)

• Set equal to "h" if you want the time to be formatted into hours (rounded to the closest 1/4 hour benchmark by default)

• Set equal to "m" if you want the time to be formatted into minutes (rounded to the closest 1/2-minute benchmark by default)

• Set equal to "s" if you want the time to be formatted into seconds (rounded to the closest 5 second benchmark by default)

bml (optional, number): The value of this argument will specify the length of the rounding benchmarks per the value of the tf argument, defaults to the values specified in the tf arguments above

Page 36: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

36 | Common Analytics Plugin Extension v2.1.2

Returns The formatTime plugin will return the number of seconds formatted using the unit you specify in the tf argument.

When the "tf" argument is not set:

• Anything less than a minute will be rounded to the closest 5 second benchmark (e.g. 10 seconds, 15 seconds, etc.)

• Anything between a minute and an hour will be rounded to the closest 1/2-minute benchmark (e.g. 30.5 minutes, 31 minutes, etc.)

• Anything between an hour and a day will be rounded to the closest quarter-hour benchmark (e.g. 2.25 hours, 3.5 hours, etc.)

• Anything greater than a day will be rounded to the closest day benchmark (e.g. 1 days, 3 days, 9 days, etc.)

Otherwise the number of seconds will be automatically formatted per the settings in the "tf" and "bml" arguments

Cookies The formatTime plugin does not create or use any cookies

Page 37: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

37 | Common Analytics Plugin Extension v2.1.2

Example Calls

Example #1 The following code…

s.eVar1 = s.formatTime(38242);

…will set s.eVar1 equal to "10.5 hours"

The argument passed in – 38242 seconds – is equal to 10 hours, 37 minutes, and 22 seconds. Since the tf argument is not set in this call and the number of seconds passed in is between an hour and a day, the plugin will return the number of second converted to the closest quarter-hour benchmark.

Example #2 The following code…

s.eVar1 = s.formatTime(38250);

…will set s.eVar1 equal to "10.75 hours"

The argument passed in – 38250 seconds – is equal to 10 hours, 37 minutes, and 30 seconds. Rounding the number of seconds passed in to the closest quarter-hour benchmark in this case will set the final value to 10.75 hours

Example #3 The following code…

s.eVar1 = s.formatTime(38242, "m");

…will set s.eVar1 equal to "637.5 minutes"

In this case, the "m" argument forces the plugin to convert the seconds to the closest ½-minute benchmark

Page 38: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

38 | Common Analytics Plugin Extension v2.1.2

Example #3 The following code…

s.eVar1 = s.formatTime(38242, "m", 20);

…will set s.eVar1 equal to "640 minutes"

The tf argument value ("m") forces the plugin to convert the seconds into minutes, but the bml argument value (20) also forces the plugin to round the minute conversion to the closest 20-minute benchmark.

Example #4 The following code…

s.eVar1 = s.formatTime(125, "s", 2);

…will set s.eVar1 equal to "126 seconds", which is the closest 2-second benchmark to 125 seconds

Example #5 The following code…

s.eVar1 = s.formatTime(125, "m", 3);

…will set s.eVar1 equal to "3 minutes", which is the closest 3-minute benchmark to 125 seconds

Example #6 The following code…

s.eVar1 = s.formatTime(145, "m", .4);

…will set s.eVar1 equal to "2.4 minutes", which is the closest 2/5ths-minute benchmark (e.g. .4 = 2/5) to 145 seconds

S Object Replacement

When instantiating the main AppMeasurement library object with a name other than "s", change the following portion of the plugin code from this…

s.formatTime=function(ns,tf,bml){

…to this:

[objectname].formatTime=function(ns,tf,bml){

Be sure to also change this…

Page 39: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

39 | Common Analytics Plugin Extension v2.1.2

s.inList=function(lv,vtc,d,cc){

…to this:

[objectname].inList=function(lv,vtc,d,cc){

Version History

1.1 (2018-05-21)

• Added the bml (benchmarkLength parameter) to allow for more flexibility in the rounding

1.0 (2018-04-15)

• Initial Release

Return to Table of Contents

Page 40: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

40 | Common Analytics Plugin Extension v2.1.2

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: formatTime v1.1 (Requires AppMeasurement and inList plugin) */ s.formatTime=function(ns,tf,bml){var s=this;if(!("undefined"===typeof ns||isNaN(ns)||0>Number(ns))){if("string"===typeof tf&&"d"===tf||("string"!==typeof tf||!s.inList("h,m,s",tf))&&86400<=ns){tf=86400;var d="days";bml=isNaN(bml)?4:tf/(bml*tf)} else"string"===typeof tf&&"h"===tf||("string"!==typeof tf||!s.inList("m,s",tf))&&3600<=ns?(tf=3600,d="hours", bml=isNaN(bml)?4: tf/(bml*tf)):"string"===typeof tf&&"m"===tf||("string"!==typeof tf||!s.inList("s",tf))&&60<=ns?(tf=60,d="minutes",bml=isNaN(bml)?2: tf/(bml*tf)):(tf=1,d="seconds",bml=isNaN(bml)?.2:tf/bml);ns=Math.round(ns*bml/tf)/bml+" "+d;0===ns.indexOf("1 ")&&(ns=ns.substring(0,ns.length-1));return ns}}; /* Adobe Consulting Plugin: inList v2.0 (Requires AppMeasurement) */ s.inList=function(lv,vtc,d,cc){if("string"!==typeof vtc)return!1;if("string"===typeof lv)lv=lv.split(d?d:",");else if("object"!==typeof lv)return!1;d=0;for(var e=lv.length;d<e;d++)if(cc&&vtc===lv[d]||!cc&&vtc.toLowerCase()=== lv[d].toLowerCase())return!0;return!1} /******************************************** END CODE TO DEPLOY ********************************************/

Page 41: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

41 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin – p_fo (pageFirstOnly)

General Details

Plugin Name: p_fo (pageFirstOnly) Latest Version: 2.0 Latest Version Save Date: 2018-04-17

Purpose

What does this plugin do? The p_fo (pageFirstOnly) plugin is a utility that checks for the existence of a specific JavaScript object. If the object doesn't exist, then the plugin creates the object and returns the value of true. This would be the first and only time the plugin would create this object on the current page (hence the name, pageFirstOnly)

If the JavaScript object already exists on the page, then the function will return the value of false

Why should I use this plugin? The doPlugins function, which is a key part of any Adobe Analytics/AppMeasurement deployment, has the potential to run multiple times per page even though certain portions of the doPlugins code might not have been meant to run so often. Inadvertently running doPlugins multiple times per page might produce inaccurate data before an image request is sent to Adobe Analytics.

p_fo allows you to add a conditional statement that will run code (in doPlugins or anywhere else) only if a specific JavaScript object hasn't been created yet on the page. If the JavaScript object hasn't yet been created, the plugin will create the object automatically, which prevents the code that would have just run from running again.

Why shouldn't I use this plugin? If you don't care how often a certain piece of JavaScript code runs on a page, then you have no need for the p_fo plugin.

Page 42: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

42 | Common Analytics Plugin Extension v2.1.2

Prerequisites You must have AppMeasurement (i.e. the base Adobe Analytics Code) to run this plugin

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code to your AppMeasurement file will help Adobe Consulting with troubleshooting any potential issues with your implementation.

Run the p_fo plugin as needed within the doPlugins function (see sample calls below)

Keep in mind that other plugins/solutions might be dependent on the p_fo plugin to work properly.

Arguments to Pass In on (required, string): The name of the JavaScript object that the plugin will create if the object doesn't yet exist on the page.

Returns

• If the object specified in the on argument doesn't exist on the page, then the plugin will create the object and return the value of true

• If the object specified in the on argument does exist on the page, then the plugin will return the value of false

Cookies The p_fo plugin does not create any cookies

Page 43: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

43 | Common Analytics Plugin Extension v2.1.2

Sample Calls

Example #1

The following code will check for the existence of the "myobject" object within the page. If the "myobject" object doesn't exist, then the code will create the "myobject" object and return the value of true. As a result, the code within the conditional statement (i.e. Console.log('hello');) will run. On the other hand, if the "myobject" object already exists when the p_fo call takes place, then the p_fo function will return the value of false and, thus, the conditional statement will be considered false. In this case, the code within the conditional statement will not run. if(s.p_fo("myobject")) { console.log("hello"); } NOTE – Everytime a new page loads (or the current page reloads), the object specified in the on argument will no longer exist and thus the p_fo plugin will again return true the first time it runs after the page finishes loading.

S Object Replacement

When instantiating the main AppMeasurement library object with a name other than "s", change the following portion of the plugin code from this… s.p_fo=function(on)

…to this: [objectname].p_fo=function(on)

Page 44: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

44 | Common Analytics Plugin Extension v2.1.2

Version History

2.0

• Point release (recompiled, smaller code size) • Changed return value type from Integer to Boolean

1.0

• Initial Release

Return to Table of Contents

Code to Pass In This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: p_fo (pageFirstOnly) v2.0 (Requires AppMeasurement) */ s.p_fo=function(on){var s=this;s.__fo||(s.__fo={});if(s.__fo[on])return!1;s.__fo[on]={};return!0}; /******************************************** END CODE TO DEPLOY ********************************************/

Page 45: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

45 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin – getAndPersistValue

General Details

Plugin Name: getAndPersistValue Latest Version: v2.0 Latest Version Save Date: 2018-04-16

Purpose of This Plugin

What does this plugin do? The getAndPersistValue plugin allows you to store a value in a cookie that can be retrieved later during a visit.

Why should I use this plugin? You should use the getAndPersistValue plugin if you want to persistently and automatically set an Analytics variable equal to the same value in every server call after the variable was initially set.

Why shouldn't I use this plugin? From a conversion perspective, the built-in persistence of eVars eliminates the need to set them equal to the same value in every server call after they were initially set. In general, if you have no need to automatically set an Analytics variable equal to the same value in every server call after the variable was initially set, then you have no need for the getAndPersistValue plugin.

Prerequisites You must have AppMeasurement (i.e. the base Adobe Analytics Code) to run the getAndPersistValue plugin

Page 46: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

46 | Common Analytics Plugin Extension v2.1.2

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code to the AppMeasurement file will help Adobe Consulting with troubleshooting any potential implementation issues.

Run the getAndPersistValue function as needed within the doPlugins function (see example calls below)

Arguments to Pass In vtp: (required) The value that is meant to persist from page to page after it has been written to the cookie specified in the cn argument

cn: (optional) The name of the cookie that will store the value to persist (as set within the vtp argument). If the cn argument is not set, then it will default to the name of "s_gapv"

ex: (optional) The number of days that the value is set to persist before it expires. If the argument is set equal to 0 (i.e. zero, without quotes) or is not set at all, the value will stop persisting at the end of the visit (i.e. after 30 minutes of inactivity)

Returns If the variable/value to be passed in via the vtp argument has been set on the current page before the getAndPersistValue plugin is called, then the plugin will first set the cookie specified in the cn argument equal to the value of the vtp argument and then return the (new) value of the cookie.

The plugin will only return the value of the cookie if the variable in the vtp argument hasn't been set on the page.

Cookies The getAndPersistValue sets a cookie with a name that you specify via the cn argument. The length of the cookie depends on the value that is persisting (i.e. the vtp argument's value). The cookie will expire depending on the value of the ex argument

Page 47: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

47 | Common Analytics Plugin Extension v2.1.2

Example Calls

Example #1 The following code will set s.eVar21 equal to the value of "hello". The code will then set the ev21gapv cookie, which will expire in 28 days, equal to the value of s.eVar21 (i.e. "hello"). The code will then (re)set s.eVar21 equal to the value of the ev21gapv cookie.

s.eVar21 = "hello"; s.eVar21 = s.getAndPersistValue(s.eVar21,"ev21gapv",28);

Example #2 Assume that s.eVar21 has not been set on the current page yet but was set equal to "hello" on a previous page within the last 28 days. The following code will only set s.eVar21 equal to the value of the ev21gapv cookie (i.e. "hello"). It does not reset the ev21gapv cookie since s.eVar21 was not set on the current page before the function was called.

s.eVar21 = s.getAndPersistValue(s.eVar21,"ev21gapv",28);

Example #3 Assume that s.eVar21 has not been set on the current page yet but was set equal to "hello" on a previous page within the last 28 days. The following code will set only s.prop35 equal to the value of the ev21gapv cookie (i.e. "hello"). It will not set eVar21.

s.prop35 = s.getAndPersistValue(s.eVar21,"ev21gapv",28);

Example #4 The following code will set s.eVar21 equal to the value of "howdy". The code will then set (or reset) the ev21gapv cookie, which will expire in 28 days, equal to the value of s.eVar21 (i.e. "howdy"). The code will then set s.prop35 equal to the value of the ev21gapv cookie (i.e. "howdy").

s.eVar21 = "howdy"; s.prop35 = s.getAndPersistValue(s.eVar21,"ev21gapv",28);

Page 48: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

48 | Common Analytics Plugin Extension v2.1.2

Example #5 Assume that s.eVar21 has not been set on any pages within the last 28 days. The following code will set s.eVar21 equal to nothing since the ev21gapv cookie would have expired 28 days after it was last set.

s.eVar21 = s.getAndPersistValue(s.eVar21,"ev21gapv",28);

Example #6 The following code will set eVar30 equal to "shopping". It will then set the s_gapv cookie, which will expire at the end of the browser session, equal to the value of s.eVar30 (i.e. "shopping"). It will then set s.eVar30 equal to the value of the s_gapv cookie (i.e. the getAndPersistValue call returns the value of the s_gapv cookie, which in this case is "shopping").

s.eVar30 = "shopping"; s.eVar30 = s.getAndPersistValue(s.eVar30);

If s.eVar30 is not set to an explicit value on any additional pages seen during the session but is set (in doPlugins) via the following code…

s.eVar30 = s.getAndPersistValue(s.eVar30);

…s.eVar30 will be set equal to "shopping" (i.e. the persisted value of the s_gapv cookie)

Page 49: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

49 | Common Analytics Plugin Extension v2.1.2

S Object Replacement

When instantiating the main AppMeasurement library object with a name other than "s", change the following portion of the plugin code from this…

s.getAndPersistValue=function(vtp, cn, ex)

…to this:

[objectname].getAndPersistValue=function(vtp, cn, ex)

Version History

2.0 (2018-04-16)

• Point Release (smaller code size) • Passing 0 into the "ex" argument now forces expiration after 30 minutes of inactivity rather than

expiration at the end of the "session".

1.0 (2016-01-18)

• First official 1.0 version (previous versions/changes undocumented)

Return to Table of Contents

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: getAndPersistValue v2.0 (Requires AppMeasurement) */ s.getAndPersistValue=function(vtp,cn,ex){var b=new Date;cn=cn?cn:"s_gapv";(ex=ex?ex:0)?b.setTime(b.getTime()+864E5*ex): b.setTime(b.getTime()+18E5);vtp||(vtp=this.c_r(cn));this.c_w(cn,vtp,b);return vtp}; /******************************************** END CODE TO DEPLOY ********************************************/

Page 50: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

50 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin – getTimeSinceLastVisit

General Details

Plugin Name: getTimeSinceLastVisit Latest Version: v1.0 Latest Version Save Date: 2019-10-07

Purpose of This Plugin

What does this plugin do? The getTimeSinceLastVisit plugin allows you to track how long a visitor has taken to return to your site after his/her last visit.

Prerequisites You must have AppMeasurement (i.e. the base Adobe Analytics Code) to run the getDaysSinceLastVisit plugin

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code to the AppMeasurement file will help Adobe Consulting with troubleshooting any potential implementation issues.

Run the getTimeSinceLastVisit function as needed within the doPlugins function (see example calls below)

Arguments to Pass In None

Returns The getTimeSinceLastVisit plugin returns the amount of time since the visitor last came to the site

Page 51: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

51 | Common Analytics Plugin Extension v2.1.2

• Any time between 30 minutes and an hour since the last visit will be set equal to the closest ½-minute benchmark (e.g. 30.5 minutes, 53 minutes, etc.)

• Any time between an hour and a day will be rounded to the closest quarter-hour benchmark (e.g. 22.5 hours, 7.5 hours, etc.)

• Anything greater than a day will be rounded to the closest day benchmark (e.g. 1 day, 3 days, 9 days, 372 days, etc.)

• “New visitor” for new visitors or for visitors that haven’t been to the site for over two years

NOTE: The getTimeSinceLastVisit plugin will return a value on only the first hit of the visit

Cookies The getDaysSinceLastVisit plugin creates a cookie called "s_tslv" that is set equal a unix timestamp representing the current time. The cookie expires after two years of inactivity.

Example Calls

Example #1

If a brand new visitor comes to the site and the following code runs on the first page of the visit … s.prop1 = s.getTimeSinceLastVisit(); s.linkTrackVars = s.apl(s.linkTrackVars, "prop1") //ensures that prop1 will be included on the first hit of the visit

… the value of s.prop1 will be “New Visitor”. If the same code runs on the same domain after 35 minutes of inactivity, the value of s.prop1 will be set equal to “35 minutes”. If the same code runs on the same domain after 4 days of further inactivity, the value of s.prop1 will be set equal to “4 days”.

Page 52: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

52 | Common Analytics Plugin Extension v2.1.2

S Object Replacement

When instantiating the main AppMeasurement library object with a name other than "s", change the following portion of the plugin code from this…

s.getTimeSinceLastVisit = function(

…to this:

[objectname].getTimeSinceLastVisit = function(

Version History

1.0 (2018-04-16)

• Point Release (recompiled code, smaller size, etc.) • Code derived from “getDaysSinceLastVisit” (now deprecated and renamed) • Now uses formatTime/inList plugins for return value

Return to Table of Contents

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: getTimeSinceLastVisit v1.0 (Requires AppMeasurement and formatTime/inList plugins) */ s.getTimeSinceLastVisit=function(){var s=this,a=new Date,b=a.getTime(),c=s.c_r("s_tslv")||0,d=Math.round((bc)/1E3);a.setTime(b+63072E6);s.c_w("s_tslv",b,a);return c?1800<d&&s.formatTime?s.formatTime(d):"":"New Visitor"}; /* Adobe Consulting Plugin: formatTime v1.1 (Requires AppMeasurement and inList plugin) */ s.formatTime=function(ns,tf,bml){var s=this;if(!("undefined"===typeof ns||isNaN(ns)||0>Number(ns))){if("string"===typeof tf&&"d"===tf||("string"!==typeof tf||!s.inList("h,m,s",tf))&&86400<=ns){tf=86400;var d="days";bml=isNaN(bml)?1:tf/(bml*tf)} else"string"===typeof tf&&"h"===tf||("string"!==typeof tf||!s.inList("m,s",tf))&&3600<=ns?(tf=3600,d="hours", bml=isNaN(bml)?4: tf/(bml*tf)):"string"===typeof tf&&"m"===tf||("string"!==typeof tf||!s.inList("s",tf))&&60<=ns?(tf=60,d="minutes",bml=isNaN(bml)?2: tf/(bml*tf)):(tf=1,d="seconds",bml=isNaN(bml)?.2:tf/bml);ns=Math.round(ns*bml/tf)/bml+" "+d;0===ns.indexOf("1 ")&&(ns=ns.substring(0, ns.length-1));return ns}}; /* Adobe Consulting Plugin: inList v2.1 (Requires AppMeasurement) */ s.inList=function(lv,vtc,d,cc){if("string"!==typeof vtc)return!1;if("string"===typeof lv)lv=lv.split(d||",");else if("object"!== typeof lv)return!1;d=0;for(var e=lv.length;d/******************************************** END CODE TO DEPLOY ********************************************/

Page 53: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

53 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin – getGeoCoordinates

General Details

Plugin Name: getGeoCoordinates Latest Version: v1.0 Latest Version Save Date: 2018-05-25

Purpose of This Plugin

What does this plugin do? The getGeoCoordinates plugin allows you to capture the geolocation (latitude and longitude) of visitors' devices.

Why should I use this plugin? You should use the getGeoCoordinates plugin if you want to capture the geolocation (latitude and longitude) of visitors' devices.

Why shouldn't I use this plugin? You won't need to use the getGeoCoordinates plugin if you don't want to capture the geolocation (latitude and longitude) of visitors' devices.

Prerequisites You must have AppMeasurement (i.e. the base Adobe Analytics Code) to run the getGeoCoordinates plugin

Page 54: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

54 | Common Analytics Plugin Extension v2.1.2

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code to the AppMeasurement file will help Adobe Consulting with troubleshooting any potential implementation issues.

• Run the getGeoCoordinates function as needed within the doPlugins function (see example calls below)

Arguments to Pass In None

Returns The getGeoCoordinates plugin returns one of the following values

• "geo coordinates not available" for devices that do not have geoCoordinates available at the time that the plugin runs. This will usually be the case on the first hit of the visit – especially when visitors first need to provide consent on tracking their location – but should not be the case afterwards.

• "error retrieving geo coordinates" if the plugin encounters any errors when trying to retrieve the device's geocoordinates

• "latitude=[LATITUDE] | longtitude=[LONGITUDE]" where [LATITUDE]/[LONGITUDE] are the latitude and longitude, respectively

NOTE: the coordinate values are rounded to the closest fourth decimal (e.g. the value of "40.438635333" would be returned as "40.4386") to limit the number of unique values to be captured. The values should be close enough to pinpoint the device's exact location within around 20 feet.

Cookies The getGeoCoordinates plugin uses the "s_ggc" cookie to store the coordinates (to be passed over from hit to hit, if necessary)

Page 55: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

55 | Common Analytics Plugin Extension v2.1.2

Example Calls

Example #1

The following code…

s.eVar1 = s.getGeoCoordinates();

…sets eVar1 equal to one of the above return values depending on the visitor's device status

Example #2 The following code extracts latitude and longitude into their own variables called finalLatitude and finalLongitude for use in other code/applications

var coordinates = s.getGeoCoordinates(); if(coordinates.indexOf("latitude") > -1) { var finalLatitude = Number(coordinates.split("|")[0].trim().split("=")[1]), finalLongitude = Number(coordinates.split("|")[1].trim().split("=")[1]); }

From there, you can determine whether a visitor is at, for example, the Statue of Liberty:

if(finalLatitude >= 40.6891 && finalLatitude <= 40.6893 && finalLongtude >= -74.0446 && finalLongitude <= -74.0444)

var visitorAtStatueOfLiberty = true; else

var visitorAtStatueOfLiberty = false;

Page 56: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

56 | Common Analytics Plugin Extension v2.1.2

S Object Replacement

When instantiating the main AppMeasurement library object with a name other than "s", change the following portion of the plugin code from this…

s.getGeoCoordinates=function()

…to this:

[objectname].getGeoCoordinates=function()

Version History

1.0 (2015-05-25)

• Initial Release

Return to Table of Contents

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: getGeoCoordinates v1.0 (Requires AppMeasurement) */ s.getGeoCoordinates=function(){var d=this,b="",a=d.c_r("s_ggc").split("|"),e={timeout:5E3,maximumAge:0},f=function(c){c=c.coords;var a=new Date;a.setTime(a.getTime()+18E5);d.c_w("s_ggc",parseFloat(c.latitude.toFixed(4))+"|"+parseFloat(c.longitude.toFixed(4)),a); b="latitude="+parseFloat(c.latitude.toFixed(4))+" | longitude="+parseFloat(c.longitude.toFixed(4))},g=function(a){b="error retrieving geo coordinates"};1<a.length&&(b="latitude="+a[0]+" | longitude="+a[1]);navigator.geolocation&& navigator.geolocation.getCurrentPosition(f,g,e);""===b&&(b="geo coordinates not available");return b}; /******************************************** END CODE TO DEPLOY ********************************************/

Page 57: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

57 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin – getNewRepeat

General Details

Plugin Name: getNewRepeat Latest Version: v2.1 Latest Version Save Date:2019-09-30

Purpose of This Plugin

What does this plugin do? The getNewRepeat plugin allows you to determine whether a visitor to the site is a new visitor or a repeat visitor within the last "x" number of days

Why should I use this plugin? You should use the getNewRepeat plugin if you want to identify visitors as being "new" if they haven't visited the site for at least "x" number of days after their last visit

Why shouldn't I use this plugin? You shouldn't use this plugin if you don't care whether the amount of time between visits should be the determining factor in labeling a legitimate repeat visitor as "new".

Adobe Analytics provides an out-of-the-box visit number report that you can leverage to determine the behavior of new visitors vs. repeat visitors. In the out-of-the-box report, the visit number will be equal to 1 if the visitor receives a new Marketing Cloud/Visitor ID cookie during the visit. The visit number will be equal to a number greater than 1 if the visitor makes a return visit to the site and already has a Marketing Cloud/Visitor ID cookie set when the visit starts.

Using this out-of-the-box data, you can create a segment that identifies visits from new visitors as the following:

Page 58: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

58 | Common Analytics Plugin Extension v2.1.2

You can create another segment that identifies visits from repeat/return visitors as the following:

Prerequisites You must have AppMeasurement (i.e. the base Adobe Analytics Code) to run the getNewRepeat plugin

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code to the AppMeasurement file will help Adobe Consulting with troubleshooting any potential implementation issues.

• Run the getNewRepeat function as needed within the doPlugins function (see example calls below)

Arguments to Pass In d (integer, optional): The minimum number of days required between visits that will identify visitors to the site as "New" visitors (even if they are return visitors). If the d parameter is not set, then it will default to the value of 30 (i.e. 30 days).

Returns The getNewRepeat plugin will return the value of "New" if the cookie set by the plugin ("s_nr") doesn't exist (or has expired) OR if the visitor continues to send image requests during the visit where the return value was initially set equal to "New".

In other words, the return value will be equal to "New" in every hit of a visit where the visitor was identified as a "New" visitor.

Page 59: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

59 | Common Analytics Plugin Extension v2.1.2

The plugin will return the value of "Repeat" if the cookie set by the plugin ("s_nr") exists and the amount of time since the current hit and the time set in the cookie is greater than 30 minutes. The plugin will also return "Repeat" if the visitor continues to send image requests during the visit where the return value was initially set equal to "Repeat".

In other words, the return value will be equal to "Repeat" in every hit of a visit where the visitor was identified as a "Repeat" visitor.

Cookies The getNewRepeat plugin creates a cookie called "s_nr[LENGTH]" where [LENGTH] is equal to the d argument, or the number of days of inactivity before a visitor is considered "New" to the site (e.g. "s_nr30", "s_nr365", etc.). The cookie will be equal to a unix timestamp representing the current time as well as the current status of the visitor (either "new" or "repeat"). The cookie will expire after the number of days of inactivity before a visitor is considered "New" has passed

Page 60: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

60 | Common Analytics Plugin Extension v2.1.2

Example Calls

Example #1 The following code will set s.eVar1 equal to the value of "New" for new visitors and will continue to set s.eVar1 equal to the value of "New" (with each new call) throughout the remainder of the visitor's visit to the site.

s.eVar1=s.getNewRepeat();

Example #2 If the visitor comes back to the site anytime from 31 minutes to 30 days since the last time s.getNewRepeat() was called, the following code will set s.eVar1 equal to the value of "Repeat" and will continue to set s.eVar1 equal to the value of "Repeat" (with each new call) throughout the remainder of the visitor's visit to the site.

s.eVar1=s.getNewRepeat();

Example #3 If the visitor hasn't been to the site for at least 30 days since the last time s.getNewRepeat() was called, the following code will set s.eVar1 equal to the value of "New" and will continue to set s.eVar1 equal to the value of "New" (with each new call) throughout the remainder of the visitor's visit to the site.

s.eVar1=s.getNewRepeat();

Example #4 If the visitor comes back to the site anytime 31 minutes to 365 days (i.e. 1 year) since the last time s.getNewRepeat() was called, the following code will set s.eVar1 equal to the value of "Repeat" and will continue to set s.eVar1 equal to the value of "Repeat" (with each new call) throughout the remainder of the visitor's visit to the site.

s.eVar1=s.getNewRepeat(365);

Page 61: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

61 | Common Analytics Plugin Extension v2.1.2

Example #5 If the visitor hasn't been to the site for at least 365 days (i.e. 1 year) since the last time s.getNewRepeat() was called, the following code will set s.eVar1 equal to the value of "New" and will continue to set s.eVar1 equal to the value of "New" (with each new call) throughout the remainder of the visitor's visit to the site.

s.eVar1=s.getNewRepeat(365);

S Object Replacement

When instantiating the main AppMeasurement library object with a name other than "s", change the following portion of the plugin code from this…

s.getNewRepeat=function(d)

…to this:

[newobjectname].getNewRepeat=function(d)

Page 62: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

62 | Common Analytics Plugin Extension v2.1.2

Version History

2.1 (2019-09-30)

• Rearrangement of JavaScript logic (for reduced plugin size)

2.0 (2018-04-16)

• Point Release (recompiled, smaller code size) • Removed the ability to name the cookie to store the visit info. The plugin will now dynamically

name the cookie based off the value passed into the d argument

1.21 (2016-05-10)

• Eliminated the need to use the s.split plugin

1.2 (2013-04-10?)

• Added the d argument, allowing the number of days specified in the argument to determine whether a visitor was considered a new visitor. Before, a visitor was always considered to be "New" after not visiting the site for at least 30 days

• Added the cn (cookie name) argument

Return to Table of Contents

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: getNewRepeat v2.1 (Requires AppMeasurement) */ s.getNewRepeat=function(d){d=d?d:30;var s=this,p="s_nr"+d,b=new Date,e=s.c_r(p),f=e.split("-"),c=b.getTime();b.setTime(c+864E5*d); if(""===e||18E4>c-f[0]&&"New"===f[1])return s.c_w(p,c+"-New",b),"New";s.c_w(p,c+"-Repeat",b);return"Repeat"}; /******************************************** END CODE TO DEPLOY ********************************************/

Page 63: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

63 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin – getPageLoadTime

General Details

Plugin Name: getPageLoadTime Latest Version: v1.0 Latest Version Save Date: 2018-05-22

Purpose of This Plugin

What does this plugin do? The getPageLoadTime plugin uses the JavaScript performance object to allow you to measure the amount of time a page takes to load completely

Why should I use this plugin? You should use the getPageLoadTime plugin if you want to measure how long your web pages take to load

Why shouldn't I use this plugin? You won't need to use the getPageLoadTime plugin if you don't need/want to track how long your pages take to load

Prerequisites You must have AppMeasurement (i.e. the base Adobe Analytics Code) and the p_fo Plugin, along with the performanceWriteFull, performanceWritePart, performanceCheck, and performanceRead helper functions (included in the Code to Deploy section below), to run the getPageLoadTime plugin

Page 64: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

64 | Common Analytics Plugin Extension v2.1.2

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code to the AppMeasurement file will help Adobe Consulting with troubleshooting any potential implementation issues.

Run the getPageLoadTime function as needed within the doPlugins function (see example calls below)

Arguments to Pass In None

Returns The getPageLoadTime plugin returns nothing but will set the following variables in the AppMeasurement object as a new page loads:

• s._pltPreviousPage = the previous page, to be correlated with the load time of the previous page

• s._pltLoadTime = the time, in seconds, that the previous page took to load.

Cookies The getPageLoadTime plugin creates two cookies:

• s_plt = the time, in seconds, that the previous page took to load

• s_pltp = the value of the s.pageName variable as recorded in the previous Adobe Analytics image request.

Both of these cookies expire when the visitor closes the browser.

Page 65: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

65 | Common Analytics Plugin Extension v2.1.2

Example Calls

Example #1 The following code…

if(s.pageName) s.getPageLoadTime(); if(s._pltPreviousPage) { s.prop10 = s._pltLoadTime; s.prop11 = s._pltPreviousPage s.eVar10 = prop11; s.events = "event100=" + s._pltLoadTime; }

• Will run the getPageLoadTime plugin when s.pageName is set

• Sets s.prop10 equal to the load time of the previous page

• Sets s.prop11 and s.eVar10 equal to the name of the previous page (as recorded in s.pageName)

• Sets event100, which would be a custom numeric event, equal to the load time of the previous page. Using a custom event in this case would allow you to get the total amount of time for all page loads of the previous page and thus use a calculated metric to get the average page load time for each page

Page 66: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

66 | Common Analytics Plugin Extension v2.1.2

S Object Replacement

When instantiating the main AppMeasurement library object with a name other than "s", change the following portion of the plugin code from this…

s.getPageLoadTime=function(lv,cn,d1)

…to this: [objectname].getPageLoadTime=function(lv,cn,d1) Also be sure to change this…

s.performanceWriteFull=function()

…to this: [objectname].performanceWriteFull=function()

And change this…

s.performanceWritePart=function()

…to this: [objectname].performanceWritePart=function()

And change this…

s.performanceCheck=function()

…to this: [objectname].performanceCheck=function()

And (finally) change this…

s.p_fo=function(on)

…to this: [objectname].p_fo=function(on)

Page 67: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

67 | Common Analytics Plugin Extension v2.1.2

Version History

1.0 (2018-05-22)

• First Official Release

Return to Table of Contents

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: getPageLoadTime v1.0 with performanceWriteFull, performanceWritePart, performanceCheck, and performanceRead helper functions (Requires AppMeasurement and the p_fo plugin) */ s.getPageLoadTime=function(){var a=this;if("undefined"!==typeof performance&&a.p_fo("performance")){var b=performance; b.clearResourceTimings();""!==a.c_r("s_plt")&&(0<b.timing.loadEventEnd&&clearInterval(a.pi),a._pltLoadTime=a.c_r("s_plt"),a._pltPreviousPage=a.c_r("s_pltp"),a.c_w("s_plt",""),a.c_w("s_pltp",""));0===b.timing.loadEventEnd?a.pi=setInterval(function(){a.performanceWriteFull()},250):0<b.timing.loadEventEnd&&(a.ptc?a.ptc===b.timing.loadEventEnd&&1===b.getEntries().length&&(a.pwp=setInterval(function(){a.performanceWritePart()},500)):a.performanceWriteFull())}}; s.performanceWriteFull=function(){var s=this,a=performance.timing;0<a.loadEventEnd&&(clearInterval(s.pi),""===s.c_r("s_plt")&& (s.c_w("s_plt",s.performanceCheck(a.loadEventEnd,a.navigationStart)),s.c_w("s_pltp",s.pageName)));s.ptc=a.loadEventEnd}; s.performanceWritePart=function(){var s=this,a=performance;0<a.getEntries().length&&(s.ppfe===a.getEntries().length? clearInterval(s.pwp):s.ppfe=a.getEntries().length);""===s.c_r("s_plt")&&(s.c_w("s_plt",((a.getEntries()[a.getEntries().length-1].responseEnd-a.getEntries()[0].startTime)/1E3).toFixed(2)),s.c_w("s_pltp",s.pageName))}; s.performanceCheck=function(a,b){if(0<=a&&0<=b)return 6E4>a-b&&0<=a-b?parseFloat((a-b)/1E3).toFixed(2):60}; /* Adobe Consulting Plugin: p_fo (pageFirstOnly) v2.0 (Requires AppMeasurement) */ s.p_fo=function(on){var s=this;s.__fo||(s.__fo={});if(s.__fo[on])return!1;s.__fo[on]={};return!0}; /******************************************** END CODE TO DEPLOY ********************************************/

Page 68: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

68 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin – getPageName

General Details

Plugin Name: getPageName Latest Version: v4.1 Latest Version Save Date: 2019-09-17

Purpose of This Plugin

What does this plugin do? The getPageName plugin creates a value that can be inserted into the Adobe Analytics pageName variable and that is an easy-to-read, "friendly"-formatted version of the current URL

Why should I use this plugin? You should use the getPageName plugin if you don't set the Analytics pageName variable within your code and your website has a very easy-to-parse-through pathing structure

Why shouldn't I use this plugin? You won't need to use the getPageName plugin if you already set the Analytics pageName variable equal to values that are easy to understand by your digital marketers. The getPageName plugin should be used as a "last resort" solution if you aren't able to provide data about how each page of your site should be named (dynamically or otherwise)

Prerequisites None

Page 69: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

69 | Common Analytics Plugin Extension v2.1.2

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code to the AppMeasurement file will help Adobe Consulting with troubleshooting any potential implementation issues.

• Run the getPageName function as needed within the doPlugins function (see example calls below)

Arguments to Pass In si (optional, string): An ID that will be inserted into the beginning of the pageName value and represents the ID of the site (e.g. friendly name, etc.); When not set, this will default to the current domain (e.g. "www.sitename.com")

qv (optional, string): A comma delimited list of query string parameters that, if found in the URL, will be added to the pageName (along with their values)

hv (optional, string): A comma delimited list of parameters found in the URL hash that, if found in the URL, will be added to the pageName (along with their values)

de (optional, string): A delimiter that will split up the individual parts of the pageName (based off the domain(ID)/path/query string parameters). Defaults to a pipe character (e.g. "|")

Returns The getPageName plugin returns a "friendly"-formatted version of the URL, to be passed into the Analytics' pageName variable, based off the criteria you specify in the arguments above

Cookies The getPageName plugin does not create or use any cookies

Page 70: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

70 | Common Analytics Plugin Extension v2.1.2

Example Calls

Example #1

If the current URL were…

https://mail.google.com/mail/u/0/#inbox

…and the following code runs…

s.pageName = getPageName()

… the final value of s.pageName will be:

s.pageName = "mail.google.com|mail|u|0";

Example #2

If the current URL were…

https://mail.google.com/mail/u/0/#inbox

…and the following code runs…

s.pageName = getPageName("gmail")

… the final value of s.pageName will be:

s.pageName = "gmail|mail|u|0";

Page 71: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

71 | Common Analytics Plugin Extension v2.1.2

Example #3

If the current URL were…

https://www.google.com/

…and the following code runs…

s.pageName = getPageName()

… the final value of s.pageName will be:

s.pageName = "www.google.com|home"

Note: URLs not containing a path will always have the value of "home" appended to the end of the value

Example #4

If the current URL were…

https://www.google.com/

…and the following code runs…

s.pageName = getPageName("google","","","|")

… the final value of s.pageName will be:

s.pageName = "google|home"

Page 72: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

72 | Common Analytics Plugin Extension v2.1.2

Example #5

If the current URL were…

https://www.hotelrooms.com/en/booking/room-booking.html?cid=1235#/step2&arrive=2018-05-26&depart=2018-05-27&numGuests=2

…and the following code runs…

s.pageName = getPageName()

… the final value of s.pageName will be:

s.pageName = "www.hotelrooms.com|en|booking|room-booking.html"

However, if the following code runs instead…

s.pageName = getPageName("hotelrooms","cid","arrive,numGuests",": ")

…the final value of s.pageName will be:

s.pageName = "hotelrooms: en: booking: room-booking.html: cid=1235: arrive=2018-05-26: numGuests=2"

Page 73: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

73 | Common Analytics Plugin Extension v2.1.2

Upgrading from Previous Versions Version 4.0+ of the getPageName plugin is not dependent on the existence of the Adobe Analytics' AppMeasurement object (i.e. the "s" object) to run. If you choose to upgrade to this version, be sure to change the code that calls the plugin by removing any instances of the "s" object from the call.

For example, change this:

s.pageName = s.getPageName();

…to this:

s.pageName = getPageName();

Version History

4.1 (2019-09-17)

• Changed default delimiter value to a pipe character (from a colon-space)

4.0 (2018-05-22) (Previous Changes Undocumented)

• Point Release (Complete Reanalysis/Rewrite of Plugin)

Return to Table of Contents

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: getPageName v4.0 (No Prerequisites Needed)*/ var getPageName=function(si,qv,hv,de){var c=location.hostname,f=location.pathname.substring(1).split("/"),h=f.length, g=location.search.substring(1).split("&"),l=g.length,k=location.hash.substring(1).split("&"),m=k.length;de=de?de:": ";si=si?si:c;qv= qv?qv:"";hv=hv?hv:"";if(1===h&&""===f[0])si=si+de+"home";else for(c=0;c<h;c++)si=si+de+decodeURIComponent(f[c]); if(qv&&(1!==l||""!== g[0]))for(f=qv.split(","),h=f.length,c=0;c<h;c++)for(qv=0;qv<l;qv++)if(f[c]===g[qv].split("=")[0]){si=si+de+decodeURIComponent(g[qv]);break}if(hv&&(1!==m||""!==k[0]))for(hv=hv.split(","),g=hv.length,c=0;c<g;c++)for(qv=0;qv<m;qv++)if(hv[c]===k[qv].split("=")[0]){si=si+de+decodeURIComponent(k[qv]);break}return si.substring(si.length-de.length)===de?si.substring(0,si.length-de.length):si}; /******************************************** END CODE TO DEPLOY ********************************************/

Page 74: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

74 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin – getPreviousValue

General Details

Plugin Name: getPreviousValue Latest Version: v2.0 Latest Version Save Date: 2018-04-16

Purpose of This Plugin

What does this plugin do? The getPreviousValue plugin allows you to set an Analytics variable equal to the value of a variable that was set on a previous page or contained in a previous image request

Why shouldn't I use this plugin? If you want to only correlate the percent of the previous page viewed with the previous page viewed, then you will not need to use this plugin. The getPercentPageViewed plugin (version 2.0+) already includes the value of the previous page name from hit to hit.

Prerequisites You must have AppMeasurement (i.e. the base Adobe Analytics Code) to run the getPreviousValue plugin

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code to the AppMeasurement file will help Adobe Consulting with troubleshooting any potential implementation issues.

Run the getPreviousValue function as needed within the doPlugins function (see example calls below)

Arguments to Pass In vtc (string, highly recommended): The Analytics variable that has the value that you want to pass over to the next image request Most cases use s.pageName (for retrieving the previous pageName value).

Page 75: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

75 | Common Analytics Plugin Extension v2.1.2

If the vtc argument is not set, then the plugin will always return the value of "no previous value" when it is called.

cn (string, optional): The name of the cookie that will store the value to be passed over to the next image request. If the cn argument is not set, then it will default to the name of "s_gpv"

el (string, optional): A comma-delimited list of Adobe Analytics events that will force the function to return the previous value specified in the vtc argument only if s.events contains any of the events in the comma-delimited list. If the el argument is not set, then the previous value specified in the vtc argument will be returned every time the getPreviousValue function runs.

Returns The getPreviousValue plugin returns the value of the variable (specified in the vtc argument) that was set on the previous page or contained in the previous image request.

The plugin returns the literal value of "no previous value" if the variable associated with the vtc argument was not set in the previous image request

The plugin will return nothing on the first page of a visit (i.e. a new visitor comes to the site OR more than 30 minutes has passed since a visitor has visited the site)

The plugin will return nothing also if the el argument is set and the s.events variable does not contain any of the values contained in the el argument at the same time the call takes place.

Cookies The getPreviousValue plugin creates a cookie, the name of which is passed in via the cn argument. The contents of the cookie contain the previous value that you want to store/retrieve. The cookie expires after 30 minutes of inactivity (i.e. end of the visit).

Page 76: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

76 | Common Analytics Plugin Extension v2.1.2

Example Calls

Example #1 The following code…

s.prop7=s.getPreviousValue(s.pageName,"gpv_Page")

• First sets s.prop7 equal to the value passed into s.pageName in the previous image request (i.e. the value stored in the "gpv_Page" cookie)

• The code will then reset the "gpv_Page" cookie, making it equal to the current value of s.pageName

• If s.pageName is not set at the time this code runs, then the code will store the literal value of "no previous value" in the "gpv_Page" cookie

Example #2

The following code sets s.prop7 equal to the value passed into s.pageName in the previous image request, but only if event1 is also contained within s.events at the time this function call takes place

s.prop7=s.getPreviousValue(s.pageName,"gpv_Page","event1")

Example #3 The following code sets s.eVar10 equal to the value passed into s.eVar1 in the previous image request. The previous eVar1 value would have been contained in the "s_gpv" cookie. The code will then set the "s_gpv" cookie equal to the current value of s.eVar1

s.eVar10=s.getPreviousValue(s.eVar1)

Page 77: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

77 | Common Analytics Plugin Extension v2.1.2

Unlikely Quirks If the variable associated with the vtc argument is set to a new value and the getPreviousValue plugin runs BUT an image request is NOT sent at the same time, the new vtc argument value will still be considered the "previous value" the next time the plugin runs

For example, assume the following code runs on the first page of the visit:

s.pageName="home" s.prop7=s.getPreviousValue(s.pageName,"gpv_Page") s.t(); This code would produce an image request where the pageName argument is equal to "home" and the p7 (prop7) argument is not set. However, the call to s.getPreviousValue would store the value of s.pageName (i.e. "home") in the cookie specified in the call (i.e. the "gpv_Page" cookie)

Now, assume that immediately afterwards, on the same page, the following code runs (for whatever reason):

s.pageName="happy value" s.prop7=s.getPreviousValue(s.pageName,"gpv_Page") Since the s.t() function does not run in this code block, another image request will not be created. However, when the s.getPreviousValue() function code runs this time, s.prop7 will be set equal to the previous value of s.pageName (i.e. "home") and then will store the new value of s.pageName (i.e. "happy value") in the "gpv_Page" cookie.

Assume the visitor navigates to a different page and the following code runs on the this page:

s.pageName="page 2" s.prop7=s.getPreviousValue(s.pageName,"gpv_Page") s.t(); When the s.t() call function runs, it will create an image request where s.pageName="page 2" and s.prop7 is equal to "happy value", which was the value of s.pageName when the last call to getPreviousValue took place. The s.prop7 value of "home" was never contained in any real image request even though "home" was the first value passed into s.pageName.

Page 78: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

78 | Common Analytics Plugin Extension v2.1.2

S Object Replacement

When instantiating the main AppMeasurement library object with a name other than "s", change the following portion of the plugin code from this…

s.getPreviousValue=function(vtc,cn,el)

…to this:

[objectname].getPreviousValue=function(vtc,cn,el)

Version History

V2.0 (2018-04-16)

• Point Release (recompiled, smaller code size) • Changed the "no value" return value to "no previous value"

v1.1 (2016-06-15)

• Removed the need for the split plugin • The code no longer requires s.events to be set before checking the el argument contents

Return to Table of Contents

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: getPreviousValue v2.0 (Requires AppMeasurement) */ s.getPreviousValue=function(vtc,cn,el){var s=this,g="",a=!0;cn=cn?cn:"s_gpv";if(el){a=!1;el=el.split(",");for(var h=s.events?s.events.split(","):"",e=0,k=el.length;e<k;e++){for(var f=0,l=h.length;f<l;f++)if(el[e]===h[f]){a=!0;break}if (!0===a)break}}!0===a&&(a=new Date,a.setTime(a.getTime()+18E5),s.c_r(cn)&&(g=s.c_r(cn)),vtc?s.c_w(cn,vtc,a):s.c_w(cn,"no previous value",a));return g}; /******************************************** END CODE TO DEPLOY ********************************************/

Page 79: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

79 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin – getQueryParam

General Details

Plugin Name: getQueryParam Latest Version: v3.3 Latest Version Save Date: 2019-09-24

Purpose of This Plugin

What does this plugin do? The getQueryParam plugin allows you to extract the value of any query string parameter contained in a URL

Why should I use this plugin? The getQueryParam plugin is an essential plugin that is used for, but not limited to:

• Extracting campaign tracking codes – both internal and external – from landing page URLs

• Extracting search terms from other query string parameters

• Etc.

If you use AppMeasurement, which has its own built-in version of the plugin (s.Util.getQueryParam), Adobe Consulting still recommends using this version of the plugin as it contains enhanced functionality that is not currently present in the below-the-line version.

Why shouldn't I use this plugin? If you have no need to extract any query string parameters from a URL, then you have no need to use the getQueryParam plugin. You may use also DTM or Analytics Processing Rules to extract query string parameters values.

Page 80: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

80 | Common Analytics Plugin Extension v2.1.2

Prerequisites To run the getQueryParam plugin, you must have the following code/plugins:

• AppMeasurement (i.e. the base Adobe Analytics Code) • pt v2.0 (plugin, included in code below)

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code to the AppMeasurement file will help Adobe Consulting with troubleshooting any potential implementation issues.

Run the getQueryParam function as needed within the doPlugins function (see example calls below)

Arguments to Pass In qsp (required): A comma delimited list of query string parameters to look for within the URL. The search will be case-insensitive.

de (optional): If the code finds multiple query string parameters in the URL (as specified in p), this parameter will be the delimiter used to separate out the individual query string parameter values as the code returns the result. Defaults to nothing (i.e. a blank string)

url (optional): A custom url/string/variable to extract the query string parameter values from. Defaults to the value of s.pageURL (or window.location).

Page 81: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

81 | Common Analytics Plugin Extension v2.1.2

Returns

• The getQueryParam plugin will return the value of the query string parameter specified in qsp • The plugin will return nothing if the query string parameter specified in qsp does not exist in the

URL • The plugin will return 'true' if the query string parameter specified in qsp exists in the URL but

does not contain a value • If the plugin finds multiple query string parameters in the URL, then it will return each of the

parameters' values concatenated together but delimited by the character(s) specified in de • If the getQueryParam call does not contain the de parameter but the code finds multiple query

string parameters in the URL, it will ultimately return each of the parameters' values concatenated together but without a delimiter to separate them.

Cookies The getQueryParam plugin does not create or use any cookies

Example Calls

Example #1 If the current URL is the following:

http://www.abc123.com/?cid=trackingcode1 The following code will set s.campaign equal to "trackingcode1":

s.campaign=s.getQueryParam('cid');

Example #2 If the current URL is the following:

http://www.abc123.com/?cid=trackingcode1&ecid=123456 The following code will set s.campaign equal to "trackingcode1:123456":

s.campaign=s.getQueryParam('cid,ecid',':');

Page 82: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

82 | Common Analytics Plugin Extension v2.1.2

Example #3 If the current URL is the following:

http://www.abc123.com/?cid=trackingcode1&ecid=123456 The following code will set s.campaign equal to "trackingcode1123456":

s.campaign=s.getQueryParam('cid,ecid');

Example #4 If the current URL is the following:

http://www.abc123.com/?cid=trackingcode1&ecid=123456#location The following code will set s.campaign equal to "123456":

s.campaign=s.getQueryParam('ecid');

Example #6 If the current URL is the following:

http://www.abc123.com/#location&cid=trackingcode1&ecid=123456 The following code will set s.campaign equal to "123456"

s.campaign=s.getQueryParam('ecid'); Note: The plugin replaces the URL to Check's hash character with a question mark if a question mark does not exist. If the URL contains a question mark that comes before the hash character, the plugin will replace the URL to Check's hash character with an ampersand;

Page 83: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

83 | Common Analytics Plugin Extension v2.1.2

Example #7 If the current URL is the following…

http://www.abc123.com/ …and if the variable s.testURL is set as follows:

s.testURL="http://www.abc123.com/?cid=trackingcode1&ecid=123456#location&pos=300"; The following code will not set s.campaign at all:

s.campaign=s.getQueryParam('cid'); However, the following code will set s.campaign equal to "trackingcode1":

s.campaign=s.getQueryParam('cid','',s.testURL); Note: the third parameter can be any string/variable that the code will use to try to find the query string parameters in

The following code will set s.eVar2 equal to "123456|trackingcode1|true|300":

s.eVar2=s.getQueryParam('ecid,cid,location,pos','|',s.testURL);

• The value of 123456 comes from the ecid parameter in the s.testURL variable

• The value of trackingcode1 comes from the cid parameter in the s.testURL variable

• The value of true comes from the existence (but non-value) of the location parameter after the hash character in the s.testURL variable

The value of 300 comes from the value of the pos parameter in the s.testURL variable

Page 84: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

84 | Common Analytics Plugin Extension v2.1.2

S Object Replacement

When instantiating the main AppMeasurement library object with a name other than "s": 1. Change the following portion of the plugin code from this…

s.getQueryParam=function(qsp,de,url)

…to this:

[objectname].getQueryParam=function(qsp,de,url)

2. And Change this…

s.pt=function(lv,de,cf,fa){

…to this:

[objectname].pt=function(lv,de,cf,fa){

Page 85: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

85 | Common Analytics Plugin Extension v2.1.2

Version History

3.2 (2018-05-15)

• Moved findParameterValue and getParameterValue functions into the getQueryParam function (vs. being outside the function)

3.1 (2018-05-10)

• Fixed bug associated with capturing query string parameters with no value

3.0 (2018-04-16)

• Point Release (Recompiled, smaller code size) • Renamed helper functions to findParameterValue and getParameterValue (for readability

purposes) • Removed the need to add an argument to find parameters contained in the URL hash

2.5 (2016-01-08)

• Now both H-code and AppMeasurement compatible (requires s.pt with AppMeasurement)

2.4 (Unknown Date)

• Added the 'h' parameter, allowing the code to find query string parameters found after the hash ("#") character

2.3 (Unknown Date)

• Fixed faulty logic in 2.2 where the plugin worked only when the hash was present after the tracking code

2.2 (Unknown Date)

• Now removes hash signs (and everything afterwards) from the return value

2.1 (Unknown Date)

• Now H.10 Compatible • Note: All versions previous to 2.1 are undocumented

Page 86: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

86 | Common Analytics Plugin Extension v2.1.2

Return to Table of Contents

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: getQueryParam v3.3 (Requires AppMeasurement and pt plugin) */ s.getQueryParam=function(qsp,de,url){var g=this,e="",k=function(b,de){de=de.split("?").join("&");de=de.split("#").join("&");var d=de.indexOf("&"),url="";b&&(-1<d||de.indexOf("=")>d)&&(d=de.substring(d+1),url=g.pt(d,"&","gpval",b));return url};qsp=qsp.split(",");var l=qsp.length;g.gpval=function(de,b){if(de){var d=de.split("="),url=d[0];d=d[1]?d[1]:!0;if(b.toLowerCase() ==url.toLowerCase())return"boolean"===typeof d?d:this.unescape(d)}return""};de=de?de:"";url=(url?url:g.pageURL?g.pageURL: location.href)+"";if((4<de.length||-1<de.indexOf("="))&&url&&4>url.length){var b=de;de=url;url=b}for(var h=0;h<l;h++)b=k(qsp[h],url) ,"string"===typeof b?(b=-1<b.indexOf("#")?b.substring(0,b.indexOf("#")):b,e+=e?de+b:b):e=""===e?b:e+(de+b);return e}; /* Adobe Consulting Plugin: pt v2.01 (Requires AppMeasurement) */ s.pt=function(l,de,cf,fa){if(l&&this[cf]){l=l.split(de||",");de=l.length;for(var e,c=0;c<de;c++)if(e=this[cf](l[c],fa))return e}}; /******************************************** END CODE TO DEPLOY ********************************************/

Page 87: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

87 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin – getResponsiveLayout

General Details

Plugin Name: getResponsiveLayout Latest Version: v1.0 Latest Version Save Date: 2018-05-02

Purpose of This Plugin

What does this plugin do? The getResponsiveLayout plugin allows you to track which version of your responsive design-based website a visitor is currently looking at

Why should I use this plugin? You should use the getResponsiveLayout plugin if your site uses responsive design and you want to track which version of the website a visitor is currently experiencing while browsing on his/her desktop/mobile device/etc.

Why shouldn't I use this plugin? You won't need to use the getResponsiveLayout plugin if your site doesn't use responsive design

Prerequisites None

Page 88: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

88 | Common Analytics Plugin Extension v2.1.2

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code to the AppMeasurement file will help Adobe Consulting with troubleshooting any potential implementation issues.

Run the getResponsiveLayout function as needed within the doPlugins function (see example calls below)

Arguments to Pass In ppw (required, integer) - Set this equal to the maximum width of pixels a browser window can have before the page switches from a phone portrait layout to a phone landscape-based layout

plw (required, integer) - Set equal to the maximum width of pixels a browser window can have before the page switches from a phone landscape layout to a tablet-based layout

tw (required, boolean) - Set equal to the maximum width of pixels a browser window can have before the page switches from a tablet layout to a desktop-based layout

Returns The getResponsiveLayout plugin returns one of the following values (depending on the browser's width and the arguments you pass into the plugin) …

• "phone portrait layout"

• "phone landscape layout"

• "phone layout" (for sites that don't have both portrait and landscape layouts)

• "tablet layout"

• "desktop layout"

… ALONG WITH the browser's width/height dimensions (e.g. "desktop layout:1243x700")

Page 89: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

89 | Common Analytics Plugin Extension v2.1.2

Cookies The getResponsiveLayout plugin does not create or use any cookies

Example Calls

Example #1

If…

• Your site switches from phone portrait mode to phone landscape mode when the browser width is greater than 500 pixels

• Your site switches from phone landscape mode to tablet mode when the browser width is greater than 700 pixels

• Your site switches from tablet mode to desktop mode when the browser width is greater than 1000 pixels

…the following code will set eVar10 equal to the current responsive design layout as experience by the visitor as well as the browser's width and dimensions

s.eVar10 = getResponsiveLayout(500, 700, 1000);

Example #2

If….

• Your site has only a phone mode, a tablet mode, and a desktop mode

• Your site switches from phone mode to tablet mode when the browser width is greater than 500 pixels

• Your site switches from tablet mode to desktop mode when the browser width is greater than 1,100 pixels

…the following code will set eVar10 equal to the current responsive design layout as experience by the visitor as well as the browser's width and dimensions

s.eVar10 = getResponsiveLayout(500, 500, 1100);

Page 90: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

90 | Common Analytics Plugin Extension v2.1.2

S Object Replacement The getResponsiveLayout plugin does not require AppMeasurement or any other plugins and thus does not need to be attached to the s object (or any other AppMeasurement object)

Version History

1.0 (2018-05-02)

• Initial Release

Return to Table of Contents

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: getResponsiveLayout v1.0 (No Prerequisites Required) */ var getResponsiveLayout=function(ppw,plw,tw){if(!(isNaN(ppw)||isNaN(plw)||isNaN(tw)||plw<ppw||tw<plw)){var b=window.innerWidth|| document.documentElement.clientWidth||document.body.clientWidth;return(ppw<plw&&b<=plw?b<=ppw?"phone portrait layout":"phone landscape layout":b<=plw?"phone layout":b<=tw?"tablet layout":"desktop layout")+":"+b+"x"+(window.innerHeight|| document.documentElement.clientHeight||document.body.clientHeight)}}; /******************************************** END CODE TO DEPLOY ********************************************/

Return to Table of Contents

Page 91: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

91 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin – getTimeBetweenEvents

General Details

Plugin Name: getTimeBetweenEvents Latest Version: v2.1 Latest Version Save Date: 2018-05-26

Purpose of This Plugin

What does this plugin do? The getTimeBetweenEvents plugin allows you to track the amount of time between two different Adobe Analytics events (custom or otherwise)

Why should I use this plugin? You should use the getTimeBetweenEvents plugin if you want to track, for example, the amount of time it takes for the checkout process to complete, or for any other process that might take a specific amount of time.

Why shouldn't I use this plugin? You won't need to use the getTimeBetweenEvents plugin if you don't need to measure the amount of time needed to complete a certain process that takes place on your website.

Prerequisites You must have AppMeasurement (i.e. the base Adobe Analytics Code) as well as the formatTime and inList plugins (included in the Code to Deploy section below) to run the getTimeBetweenEvents plugin

Page 92: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

92 | Common Analytics Plugin Extension v2.1.2

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code to the AppMeasurement file will help Adobe Consulting with troubleshooting any potential implementation issues.

Run the getTimeBetweenEvents function as needed within the doPlugins function (see arguments and example calls below)

Page 93: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

93 | Common Analytics Plugin Extension v2.1.2

Arguments to Pass In

• ste (required, string): startTimerEvents, or a comma-separated list of Adobe Analytics events that will "start the timer"

• rt (required, boolean): restartTimer

o set equal to true if you want to restart the timer every time s.events contains an event in the start-timer (ste) argument

o set equal to false if you don't want to restart the timer every time s.events contains an event in the ste argument. This means only the first instance of s.events containing a "start-timer" event will actually start the timer

• stp (required, string): stopTimerEvents, or a comma-separated list of Adobe Analytics events that will "stop the timer"

• res (required, boolean) resetTimer:

o Set equal to true if you want to record the time since the timer started AND reset the timer (when s.events contains an event in the stop-timer, or stp argument)

o set equal to false if you want to only record the time since the timer started (when s.events contains an event in the stp argument). This means the timer will continue to run after the events variable has recorded a stop event.

o Thus, when the res argument is set equal to false, setting the rte argument (see below) is highly recommended (defaults to true)

• cn (optional, string): The cookieName where the time of the first event is stored; (defaults to "s_tbe")

• etd (optional, integer): expireTimerInDays, or the expiration time for the cn cookie in days - set to 0 for session (defaults to 1 day when not set)

• fmt (optional, string): the format of the time that the number of seconds will be returned in (defaults to nothing)

o "s" for seconds o "m" for minutes o "h" for hours o "d" for days o When not set, the return value's format will be based off the following rules:

Anything less than a minute will be rounded to the closest 5 second benchmark (e.g. 10 seconds, 15 seconds, etc.)

Anything between a minute and an hour will be rounded to the closest 1/2-minute benchmark (e.g. 30.5 minutes, 31 minutes, etc.)

Anything between an hour and a day will be rounded to the closest quarter-hour benchmark (e.g. 2.25 hours, 3.5 hours, etc.)

Anything greater than a day will be rounded to the closest day benchmark (e.g. 1 days, 3 days, 9 days, etc.)

Page 94: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

94 | Common Analytics Plugin Extension v2.1.2

• bml (optional, number): benchmarkLength, or the length of the rounding benchmark according to the format of the fmt argument

o For example, if the fmt argument is equal to "s" and the bml argument is equal to 2, the return value will be rounded to the closest 2-second benchmark

o Or, if the fmt argument is equal to "m" and the bml argument is equal to .5, the return value will be rounded to the closest 1/2-minute benchmark

• rte (optional, string): removeTimerEvents, or a comma-separated list of Adobe Analytics events that will remove/delete the timer (defaults to nothing)

Returns The getTimeBetweenEvents plugin returns the amount of time between any of the events specified in the "ste" argument and any of the events specified in the "stp" argument (per the rules explained above)

Cookies The getTimeBetweenEvents plugin does creates a cookie with the name specified in the "cn" argument (defaults to "s_tbe") and is equal to a Unix timestamp representing the timer's start time. The cookie will expire after the number of days specified in the "etd" argument (when set) or when the visitor closes his/her browser (when the "etd" argument is not set)

Example Calls

Example #1

The following code…

s.eVar1 = s.getTimeBetweenEvents("event1", true, "event2", true, "", 0, "s", 2, "event3");

…is configured to behave as follows:

• The timer will start when s.events contains event1.

• The timer will restart every time s.events contains event1

• The timer will stop when s.events contains event2

• The timer will reset (i.e. go to 0 seconds) every time s.events contains event2

• The timer will reset also when either s.events contains event3 OR if the visitor closes his/her browser

• When an actual time between event1 and event2 is recorded, the plugin will set eVar1 equal to the number of seconds between the two events being set, rounded to the closest 2-second benchmark (e.g. 0 seconds, 2 seconds, 4 seconds, 10 seconds, 184 seconds, etc.)

Page 95: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

95 | Common Analytics Plugin Extension v2.1.2

• If s.events contains event2 before a timer has started, eVar1 won't be set at all.

Page 96: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

96 | Common Analytics Plugin Extension v2.1.2

Example #2

The following code…

s.eVar1 = s.getTimeBetweenEvents("event1", false, "event2", false, "s_20", 20, "h", 1.5, "event3");

…is configured to behave as follows:

• The timer will start when s.events contains event1.

• The timer will NOT restart every time s.events contains event1, rather the original timer will still keep running

• The timer will NOT stop when s.events contains event2, but the plugin will record the time since the original event1 setting was recorded

• The timer will be stored in a cookie called "s_20"

• The timer will reset only when either s.events contains event3 OR if 20 days has passed since the timer started

• When a time between (the original) event1 and event2 is recorded, the plugin will set eVar1 equal to the number of hours between the two events being set, rounded to the closest 1 1/2-hour benchmark (e.g. 0 hours, 1.5 hours, 3 hours, 7.5 hours, 478.5 hours, etc.)

Example #3

The following code…

s.eVar1 = s.getTimeBetweenEvents("event1", true, "event2", true);

…will produce similar results to the first example above; however, the value of eVar1 will be returned in either seconds, minutes, hours, or days, depending on the final length of the timer. Also, the timer will expire 1 day after it was first set instead of at the time the visitor closes his/her browser.

Page 97: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

97 | Common Analytics Plugin Extension v2.1.2

S Object Replacement When instantiating the main AppMeasurement library object with a name other than "s", change the following portion of the plugin code from this…

s.getTimeBetweenEvents=function(ste,rt,stp,res,cn,etd,fmt,bml,rte)

…to this:

[objectname].getTimeBetweenEvents=function(ste,rt,stp,res,cn,etd,fmt,bml,rte)

Also be sure to change this…

s.formatTime=function(ns,tf,bml)

…to this:

[objectname].formatTime=function(ns,tf,bml)

And change this…

s.inList=function(lv,vtc,d,cc){

…to this:

[objectname].inList=function(lv,vtc,d,cc){

Version History

2.1 (2018-05-26)

• Accommodate changes to new version of the formatTime plugin

2.0 (2018-04-06) (Previous Changes Undocumented)

• Complete Rewrite/Reanalysis of Plugin

Return to Table of Contents

Page 98: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

98 | Common Analytics Plugin Extension v2.1.2

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: getTimeBetweenEvents v2.1 (Requires AppMeasurement; also formatTime and inList plugins) */ s.getTimeBetweenEvents=function(ste,rt,stp,res,cn,etd,fmt,bml,rte){var s=this;if("string"===typeof ste&&"undefined"!==typeof rt&&"string"===typeof stp&&"undefined"!==typeof res){cn=cn?cn:"s_tbe";etd=isNaN(etd)?1:Number(etd);var f=!1,g=!1,n=ste.split(",") ,p=stp.split(",");rte=rte?rte.split(","):[];for(var h=s.c_r(cn),k,u=new Date,q=u.getTime(),b=new Date,a=0;a<rte.length;++a) if(s.inList(s.events,rte[a])){b.setDate(b.getDate()-1);s.c_w(cn,"",b);return}b.setTime(b.getTime()+864E5*etd);for(a=0; a<n.length&&!f&&(f=s.inList(s.events,n[a]),!0!==f);++a);for(a=0;a<p.length&&!g&&(g=s.inList(s.events,p[a]),!0!==g);++a);1===n.length&&1===p.length&&ste===stp&&f&&g?(h&&(k=(q-h)/1E3),s.c_w(cn,q,etd?b:0)):(!f||1!=rt&&h||s.c_w(cn,q,etd?b:0),g&&h&&(k=(u.getTime()-h)/1E3,!0===res&&(b.setDate(b.getDate()-1),s.c_w(cn,"",b))));return k?s.formatTime(k,fmt,bml):""}}; /* Adobe Consulting Plugin: formatTime v1.1 (Requires AppMeasurement and inList plugin) */ s.formatTime=function(ns,tf,bml){var s=this;if(!("undefined"===typeof ns||isNaN(ns)||0>Number(ns))){if("string"===typeof tf&&"d"===tf||("string"!==typeof tf||!s.inList("h,m,s",tf))&&86400<=ns){tf=86400;var d="days";bml=isNaN(bml)?4:tf/(bml*tf)} else"string"===typeof tf&&"h"===tf||("string"!==typeof tf||!s.inList("m,s",tf))&&3600<=ns?(tf=3600,d="hours", bml=isNaN(bml)?4: tf/(bml*tf)):"string"===typeof tf&&"m"===tf||("string"!==typeof tf||!s.inList("s",tf))&&60<=ns?(tf=60,d="minutes",bml=isNaN(bml)?2: tf/(bml*tf)):(tf=1,d="seconds",bml=isNaN(bml)?.2:tf/bml);ns=Math.round(ns*bml/tf)/bml+" "+d;0===ns.indexOf("1 ")&&(ns=ns.substring(0,ns.length-1));return ns}}; /* Adobe Consulting Plugin: inList v2.0 (Requires AppMeasurement) */ s.inList=function(lv,vtc,d,cc){if("string"!==typeof vtc)return!1;if("string"===typeof lv)lv=lv.split(d?d:",");else if("object"!==typeof lv)return!1;d=0;for(var e=lv.length;d<e;d++)if(cc&&vtc===lv[d]||!cc&&vtc.toLowerCase()=== lv[d].toLowerCase())return!0;return!1} /******************************************** END CODE TO DEPLOY ********************************************/

Page 99: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

99 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin - getTimeParting

General Details

Plugin Name: getTimeParting Latest Version: 6.2 Latest Version Save Date: 2019-11-05

Purpose

What does this plugin do? The getTimeParting plugin provides a complete analytics solution that allows a client to capture the details of the time when any measurable activity takes place on its site.

Why should I use this plugin? You should use the getTimeParting plugin if you wish to breakdown your metrics by any repeatable division of time over a given date range. For example, the getTimeParting plugin will allow you to compare conversion rates between two different days of the week (e.g. all Sundays vs. all Thursdays), two different periods of the day (e.g. all mornings vs. all evenings), or even two subsequent minutes (e.g. all 10:00 AM instances vs. all 10:01 AM instances) for the date range you specify in the report.

Analysis Workspace provides similar, out-of-the-box dimensions that are formatted/provided in a slightly different manner than what this plugin provides (see here), so Adobe Consulting recommends you read through the remainder of this document (and the aforementioned link to the help section) to determine whether this plugin provides data in a manner that's more suited to your needs.

Page 100: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

100 | Common Analytics Plugin Extension v2.1.2

Why shouldn't I use this plugin? If you don't care about breaking down your metrics by a repeatable division of time over a specific date range, then you will not need to use the getTimeParting plugin. Also, if you find the Analysis Workspace Time-Parting Dimensions sufficient, then you will not need to implement this plugin.

Please note: the solution that version 4.0+ of the getTimeParting plugin provides is much different than what earlier versions of the plugin have provided. If you choose to upgrade from a version before 4.0, you should implement the solution "from scratch". In other words, you should setup a completely brand new eVar – one eVar – to hold the data provided by the plugin and read through this documentation carefully before implementing the solution.

Also: This version of the plugin is not fully compatible with Microsoft Internet Explorer browsers, although the plugin is fully compatible with Microsoft Edge browsers. Visitors that use Internet Explorer will be able to provide the time but only in their local time zone rather than converted to the time zone you specify. See the examples below for a solution that will not include data from Internet Explorer browsers but will still account for their presence.

Prerequisites None

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code to your AppMeasurement file will help Adobe Consulting with troubleshooting any potential issues with your implementation.

Run the getTimeParting function within the doPlugins function (see sample calls below)

Page 101: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

101 | Common Analytics Plugin Extension v2.1.2

Arguments to Pass In t: (OPTIONAL but recommended, string) The name of the time zone to convert the visitor's local time to. Defaults to “Etc/GMT”, or UTC/GMT time. Visit https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for the complete list of values to enter.

Common values include:

• "America/New_York" for Eastern Time • "America/Chicago" for Central Time • "America/Denver" for Mountain Time • "America/Los_Angeles" for Pacific Time

Returns The getTimeParting plugin returns a string containing the following:

• The current year • The current month • The current date (i.e. day of the month) • The current day (i.e. day of the week) • The current time (non-military time)

Each of the above items is delimited by a pipe ("|") character.

Cookies The getTimeParting plugin does not create any cookies

Page 102: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

102 | Common Analytics Plugin Extension v2.1.2

Example Calls

Examples for Specific Time Zones

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 plugin argument will be necessary under such circumstances.

Accounting for Internet Explorer Browsers Use the following sample if you want to exclude time parting data from Internet Explorer Visitors (since the value returned from IE browsers can be in only the visitor's local time)

if(!document.documentMode) s.eVarX = getTimeParting("America/New_York"); else s.eVarX = "Internet Explorer Visitors";

Page 103: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

103 | Common Analytics Plugin Extension v2.1.2

Results from calls

If a visitor from Denver, Colorado visits a site on August 31, 2018 at 9:15 AM, the following code…

s.eVar10 = getTimeParting("Europe/Athens");

…would set s.eVar10 equal to "year=2018 | month=August | date=31 | day=Friday | time=6:15 PM" The following code…

s.eVar10 = getTimeParting("America/Nome");

… would set s.eVar10 equal to "year=2018 | month=August | date=31 | day=Friday | time=6:15 AM" The following code…

s.eVar10 = getTimeParting("Asia/Calcutta");

… would set s.eVar10 equal to "year=2018 | month=August | date=31 | day=Friday | time=8:45 PM" The following code…

s.eVar10 = getTimeParting("Australia/Sydney");

… would set s.eVar10 equal to "year=2018 | month=September | date=1 | day=Saturday | time=1:15 AM"

Page 104: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

104 | Common Analytics Plugin Extension v2.1.2

S Object Replacement The getTimeParting plugin does not require AppMeasurement or any other plugins and thus does not need to be attached to the s object (or other AppMeasurement object)

Reporting/Backend Setup (Requires Admin Access)

eVar setup Setup the eVar that will hold the time parting data with the following attributes:

• Name: Time Parting • Allocation: Most Recent (Last) • Expire After: Visit • All other attributes use the default values provided

Page 105: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

105 | Common Analytics Plugin Extension v2.1.2

Classification Setup The data provided by the getTimeParting plugin is extremely granular, but using the Adobe Analytics' classification rule builder will allow you to automatically roll up the values produced by the plugin into more managable high-level dimensions.

These instructions assume you have already setup the eVar that will capture Time Parting data.

1. Access the Analytics' Report Suite Manager via the top menu:

2. Select the report suite(s) that contain the Time Parting eVar and select Edit Settings > Conversion > Conversion Classifications:

3. In the "Select Classification Type" drop down box that appears in the Conversion Classifications page, select the time parting eVar.

Page 106: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

106 | Common Analytics Plugin Extension v2.1.2

4. Use the right-hand arrow icon and the Add Classification menu option…

… to add the following classifications:

• Time Parting Year • Time Parting Month • Time Parting Date of the Month • Time Parting Day of the Week • Time Parting Weekday/Weekend • Time Parting Day Period • Time Parting Hour of the Day • Time Parting Half-Hour of the Day • Time Parting Time of Day

Page 107: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

107 | Common Analytics Plugin Extension v2.1.2

Classification Rules Initial Setup These instructions assume you have already setup the classifications described above

1. Access the Classification Rule Builder via the top Admin menu:

2. Click on "Add Rule Set" and give the rule set the name of "Time Parting"

3. Select the "Time Parting" Rule Set

Page 108: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

108 | Common Analytics Plugin Extension v2.1.2

4. Click on the "Select Report Suites and Variables" link

5. When Select Report Suite/Variables popup box appears, click on the "Add" button on the lower-right hand side of the box

6. A drop-down box will appear. Select the report suite that contains the Time Parting eVar (and classifications)

7. Another drop-down box will appear. In this dropdown box, select the Time Parting eVar. If the Time Parting eVar does not appear in the dropdown, then check and make sure that the eVar has its classifications setup per the instructions above

8. Click on the "Save" button

Page 109: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

109 | Common Analytics Plugin Extension v2.1.2

Classification Rule Builder

1. Using the classification rule builder interface…

…create rules using the following criteria:

Rule Type Match Criteria Set Classification To Regular Expression year=(.*?)\||$ Time Parting Year $1 Regular Expression month=(.*?)\||$ Time Parting Month $1 Regular Expression date=(.*?)\||$

Time Parting Date of the Month $1

Regular Expression day=(.*?)\||$ Time Parting Day of the Week $1 Regular Expression day=(M|T|W|F|m|t|w|f)

Time Parting Weekday/Weekend Weekday

Regular Expression day=(S|s)

Time Parting Weekday/Weekend Weekend

Regular Expression

time=(12|1|2|3|4|5)\:.*?(AM|am) Time Parting Day Period

Early Morning

Regular Expression

time=(6|7|8|9|10|11)\:.*?(AM|am) Time Parting Day Period Morning

Regular Expression

time=(12|1|2|3|4|5)\:.*?(PM|pm) Time Parting Day Period Afternoon

Regular Expression

time=(6|7|8|9|10|11)\:.*?(PM|pm) Time Parting Day Period Evening

Regular Expression time=(.*)\:.*?(AM|am|PM|pm) Time Parting Hour of the Day $1:00 $2 Regular Expression

time=(.*)\:(0|1|2).*?(AM|am|PM|pm)

Time Parting Half-hour of the Day $1:00 $3

Regular Expression

time=(.*)\:(3|4|5).*?(AM|am|PM|pm)

Time Parting Half-hour of the Day $1:30 $3

Regular Expression time=(.*?)$ Time Parting Time of Day $1

2. Once you have filled out the rules, you may test them using the Test Rule Set button

Page 110: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

110 | Common Analytics Plugin Extension v2.1.2

3. Click on the Activate Button to activate your rule set and begin the automatic classification process for all incoming values

Access the Reports Via Analytics Workspace or Reports, you may generate segments and dashboards based off the newly classified dimensions that you have setup

Page 111: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

111 | Common Analytics Plugin Extension v2.1.2

Version History

6.1 (2018-11-26)

• Fix for Internet Explorer Browsers. IE browsers is able return the time, but in only the visitor’s local time.

6.0 (2018-08-14)

• Complete rewrite to accommodate International Standards (now converts daylight savings and all time zones appropriately)

5.0 (2018-04-17)

• Point Release (recompiled, smaller code size) • Removed the need for the s.tpDST parameter to be set as daylight savings start/end dates will

now be detected automatically

4.0 (2016-08-22) - Changes in previous versions not available

• Version 4.0 provides a completely brand new solution and now includes Year/Month/Date information

Return to Table of Contents

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: getTimeParting v6.2 (No Prerequisites Needed) */ 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 ********************************************/

Page 112: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

112 | Common Analytics Plugin Extension v2.1.2

Page 113: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

113 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin –getTimeToComplete

General Details

Plugin Name: getTimeToComplete Latest Version: 3.1 Latest Version Save Date: 2018-08-23

Purpose

What does this plugin do? The getTimeToComplete plug-in will track the time a user takes to complete a process on a site. The "clock" begins when the "start" action is called and ends when the "stop" action is called.

Why should I use this plugin? This plugin is useful if there is a workflow on the site that takes some time to complete and the business would like to know how much time visitors are taking to complete it.

Why shouldn't I use this plugin? This plugin is not useful if the workflow on the site only takes a short period of time (less than 3 seconds) because the granularity is only down to the full second.

Prerequisites You must have AppMeasurement (i.e. the base Adobe Analytics Code) as well as the formatTime and inList plugins (provided below) to run this plugin

Page 114: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

114 | Common Analytics Plugin Extension v2.1.2

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code to your AppMeasurement file will help Adobe Consulting with troubleshooting any potential issues with your implementation.

When the workflow on the site is started, call the getTimeToComplete function with the "start" action to start the timer.

When the visitor is finished with the workflow, call the getTimeToComplete function with the "stop" action to stop the timer.

Arguments to Pass In sos (optional, string): set equal to "start" in cases where you want to start a timer; otherwise set equal to "stop" in cases where you want to stop the timer; defaults to "start"

cn (optional, string): the name of the cookie that will store the start time; defaults to "s_gttc"

exp (optional, integer): the number of days that the timer will run (after being started) before it will expire; defaults to 0, when the timer will expire at the end of the session

Returns The getTimeToComplete plugin returns the number of days, hours, minutes and/or seconds it took between the "start" and "stop" action.

Cookies The getTimeToComplete plugin creates/reads from a cookie with the name specified in the cn argument. The value of the cookie is equal to a unix timestamp that represents the timer start time. The cookie expires at the time specified in the exp argument.

Page 115: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

115 | Common Analytics Plugin Extension v2.1.2

Example Calls

Example #1

Use these calls to determine the time between when a visitor starts the checkout process and when they make a purchase. Start the timer when the visitor starts the checkout:

if(s.events.indexOf("scCheckout") > -1) s.getTimeToComplete("start");

Stop the timer when the visitor makes the purchase and set prop1 to the time difference between stop and start:

if(s.events.indexOf("purchase") > -1) s.prop1 = s.getTimeToComplete("stop");

s.prop1 will capture the amount of time needed to complete the purchase process

Example #2

If you want to have several timers running at the same time (to measure different processes), you will need to manually set the cn cookie argument. For example, if you want to measure the amount of time needed for a purchase to complete, you would set the following code… if(s.inList(s.events, "scCheckout")) s.getTimeToComplete("start", "gttcpurchase"); if(s.inList(s.events, "purchase")) s.prop1 = s.getTimeToComplete("start", "gttcpurchase"); … but if you also wanted to measure (at the same time) the amount of time needed for a registration form to be filled out, you would run the following code as well:

if(s.inList(s.events, "event1")) s.getTimeToComplete("start", "gttcregister", 7); if(s.inList(s.events, "event2")) s.prop2 = s.getTimeToComplete("stop", "gttcregister", 7);

In the above code example, event1 is meant to capture the beginning of a registration process that could take up to 7 days to complete, for whatever reason, and event2 is meant to capture the completion of the registration. s.prop2 will capture the amount of time needed to complete the registration process

Note: the inList plugin as shown above is provided separately

Page 116: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

116 | Common Analytics Plugin Extension v2.1.2

S Object Replacement

When instantiating the main AppMeasurement library object with a name other than "s", change the following portion of the plugin code from this… s.getTimeToComplete=function(sos,cn,exp)

…to this: [objectname].getTimeToComplete=function(sos,cn,exp)

Version History

3.0 (2018-08-23)

• No change to the getTimeToComplete plugin code, but replaced the formatTime v1.0 plugin code with the formatTime v1.1 plugin code

3.0 (2018-04-17)

• Point Release (recompiled, smaller code size) • Minor bug fixes

2.0 (2016-06-21) – previous versions undocumented

• Eliminated the dependency on the "s.p_fo" (page first only) plugin. • Added compatibility with H-code and AppMeasurement. • Added console logging

Return to Table of Contents

Page 117: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

117 | Common Analytics Plugin Extension v2.1.2

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: getTimeToComplete v3.1 (Requires AppMeasurement; also the formatTime and inList plugins) */ s.getTimeToComplete=function(sos,cn,exp){sos=sos?sos.toLowerCase():"start";if("stop"===sos||"start"===sos){cn=cn?cn:"s_gttc";exp=exp?exp:0;var s=this,d=s.c_r(cn),e=new Date;if("start"===sos&&!d)s.c_w(cn,e.getTime(),exp?new Date(e.getTime()+864E5*exp):0);else if("stop"===sos&&d)return sos=Math.round((e.getTime()-d)/1E3),s.c_w(cn,"",0),s.formatTime(sos)}}; /* Adobe Consulting Plugin: formatTime v1.1 (Requires AppMeasurement and inList plugin) */ s.formatTime=function(ns,tf,bml){var s=this;if(!("undefined"===typeof ns||isNaN(ns)||0>Number(ns))){if("string"===typeof tf&&"d"===tf||("string"!==typeof tf||!s.inList("h,m,s",tf))&&86400<=ns){tf=86400;var d="days";bml=isNaN(bml)?1:tf/(bml*tf)} else"string"===typeof tf&&"h"===tf||("string"!==typeof tf||!s.inList("m,s",tf))&&3600<=ns?(tf=3600,d="hours", bml=isNaN(bml)?4: tf/(bml*tf)):"string"===typeof tf&&"m"===tf||("string"!==typeof tf||!s.inList("s",tf))&&60<=ns?(tf=60,d="minutes",bml=isNaN(bml)?2: tf/(bml*tf)):(tf=1,d="seconds",bml=isNaN(bml)?.2:tf/bml);ns=Math.round(ns*bml/tf)/bml+" "+d;0===ns.indexOf("1 ")&&(ns=ns.substring(0,ns.length-1));return ns}};

/* Adobe Consulting Plugin: inList v2.1 (Requires AppMeasurement) */ s.inList=function(lv,vtc,d,cc){if("string"!==typeof vtc)return!1;if("string"===typeof lv)lv=lv.split(d||",");else if("object"!== typeof lv)return!1;d=0;for(var e=lv.length;d<e;d++)if(1==cc&&vtc===lv[d]||vtc.toLowerCase()===lv[d].toLowerCase())return!0;return!1}; /******************************************** END CODE TO DEPLOY ********************************************/

Page 118: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

118 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin –getValOnce

General Details

Plugin Name: getValOnce Latest Version: 2.0 Latest Version Save Date: 2018-04-17

Purpose

What does this plugin do? The getValOnce plugin prevents a variable from being set equal to the same value twice in a row (or more)

Why should I use this plugin? The getValOnce plugin is useful in situations where your organization would like to deduplicate, for example, multiple campaign click-through instances that might occur when users refresh a landing page or come back to the landing page via hitting the browser's back button.

Why shouldn't I use this plugin? You your organization does not need to deduplicate a variable's value, then you won't need to use this plugin.

Prerequisites You must have AppMeasurement (i.e. the base Adobe Analytics Code) to run this plugin

Page 119: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

119 | Common Analytics Plugin Extension v2.1.2

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code to your AppMeasurement file will help Adobe Consulting with troubleshooting any potential issues with your implementation.

• Run the getValOnce function as needed within the doPlugins function - see the sample calls below.

Arguments to Pass In vtc (required, string) - the variable to check and see whether it was just previously set to an identical value

cn (optional, string) - the name of the cookie that will hold the value to check against, defaults to "s_gvo"

et (optional, integer) - a number that specifies when the cn cookie will hit its expire time (in "x" minutes/days), defaults to 0, which forces the cn cookie to expire at the end of the session

ep (optional, string) - the extend period unit, defaults to "d" (i.e. days)

• If the "et" argument is an integer not equal to 0, set the "ep" argument equal to "m" if you want the "cn" cookie to expire in "x" number of minutes

• OR set the "ep" argument equal to "d" if you want the "cn" cookie to expire in "x" number of days

Returns If the variable specified in the vtc parameter has the exact same value as before, the plugin will return an empty string; otherwise it will return the (new) value.

Cookies The getValOnce plugin creates a cookie with a name equal to the name passed in via the cn argument. It's value is equal to the value contained in the vtc argument and its expiration is dependent on the values passed in via the et/ep arguments.

Page 120: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

120 | Common Analytics Plugin Extension v2.1.2

Example Calls

Example #1

Use this call to prevent the same value being passed in to s.campaign more than once in a row for next 30 days- s.campaign=s.getValOnce(s.campaign,"s_campaign",30);

In the above call, s_campaign cookie will store the value coming from s.campaign variable and compare the values for last 30 days. s.campaign will return new value if values doesn’t match with the s_campaign.

Example #2

Use this call to prevent the same value being set throughout the session s.eVar2=s.getValOnce(s.eVar2,"s_ev2",0,"m");

The same value from being passed into s.eVar2 more than once in a row throughout the session; ignores the m value in the t parameter since the expiration parameter is set equal to 0. Stores the comparison value in the s_ev2 cookie.

S Object Replacement

When instantiating the main AppMeasurement library object with a name other than "s", change the following portion of the plugin code from this… s.getValOnce=function(vtc,cn,et,ep)

…to this: [objectname].getValOnce=function(vtc,cn,et,ep)

Page 121: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

121 | Common Analytics Plugin Extension v2.1.2

Version History

2.0

• Point Release (recompiled, smaller code size)

1.1

• Added the option to choose minutes or days for the expiration via the 't' parameter'. • Corrected the scope of the k variable used to restrict it to the plugin only. (to prevent possible

interaction with other js code on the customer’s page).

Return to Table of Contents

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: getValOnce v2.0 (Requires AppMeasurement) */ s.getValOnce=function(vtc,cn,et,ep){cn=cn?cn:"s_gvo";et=et?et:0;ep="m"===ep?6E4:864E5;if(vtc&&vtc!==this.c_r(cn)){var e=new Date;e.setTime(e.getTime()+et*ep);this.c_w(cn,vtc,0===et?0:e);return vtc}return""}; /******************************************** END CODE TO DEPLOY ********************************************/

Page 122: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

122 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin – getVisitDuration

General Details

Plugin Name: getVisitDuration Latest Version: v2.0 Latest Version Save Date: 2019-09-24

Purpose of This Plugin

What does this plugin do? The getVisitDuration plugin tracks the amount of time (in minutes) that the visitor has been on the site up to that point.

Why should I use this plugin? You should use the getVisitDuration plugin if you want to track how long (in minutes) a visitor might have taken to perform a certain activity (e.g. purchase, lead generation, etc.) after landing on the site

Why shouldn't I use this plugin? You won't need to use the getVisitDuration plugin if you don’t need/want to track how many minutes it took a visitor to perform a certain activity. Also, this plugin does not track the amount of time between events; this merely tracks the amount of time since the visitor landed on the site.

Prerequisites You must have AppMeasurement (i.e. the base Adobe Analytics Code) to run the getVisitDuration plugin

Page 123: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

123 | Common Analytics Plugin Extension v2.1.2

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code to the AppMeasurement file will help Adobe Consulting with troubleshooting any potential implementation issues.

Run the getVisitDuration function as needed within the doPlugins function (see example calls below)

Arguments to Pass In None

Returns The getVisitDuration plugin returns one of the following values depending on the situation

• "first hit of visit" • “less than a minute” • “1 minute” • “[x] minutes” (where [x] is the number of minutes passed since the visitor landed on the site)

Cookies The getVisitDuration plugin creates a cookie called “s_dur”, which is equal to the number of milliseconds passed since the visitor landed on the site. The cookie expires after 30 minutes of inactivity (i.e. end of the visit)

Page 124: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

124 | Common Analytics Plugin Extension v2.1.2

Example Calls

Example #1

The following code…

s.eVar10 = s.getVisitDuration();

…will always set eVar10 equal to the number of minutes passed since the visitor landed on the site

Example #2

The following code…

if(s.inList(s.events, "purchase")) s.eVar10 = s.getVisitDuration();

…uses the inList plugin to check whether the events variable contains the purchase event. If so, then eVar10 will be set equal to the number of minutes between the visitor's start of the visit and the time of purchase.

Example #3

The following code…

s.prop10 = s.getVisitDuration();

…will always set prop10 equal to the number of minutes passed since the visitor landed on the site. This will be useful if prop10 has pathing enabled. Adding the "exits" metric to the prop10 report will show a granular, "scatterplot" report of how long a visit took in minutes before a visitor left the site.

Page 125: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

125 | Common Analytics Plugin Extension v2.1.2

S Object Replacement

When instantiating the main AppMeasurement library object with a name other than "s", change the following portion of the plugin code from this…

s.getVisitDuration=function()

…to this:

[objectname].getVisitDuration=function()

Version History

2.0 (2018-05-02) (previous changes undocumented)

• Point Release (complete reanalysis/rewrite of plugin)

Return to Table of Contents

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: getVisitDuration v2.0 (Requires AppMeasurement) */ s.getVisitDuration=function(){var d=new Date,c=d.getTime(),b=this.c_r("s_dur");if(isNaN(b)||18E5<c-b)b=c;var a=c-b;d.setTime(c+18E5); this.c_w("s_dur",b+"",d);if(0===a)return"first hit of visit";a=Math.floor(a/6E4);return 0===a?"less than a minute":1===a?"1 minute": a+" minutes"}; /******************************************** END CODE TO DEPLOY ********************************************/

Page 126: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

126 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin– getVisitNum

General Details

Plugin Name: getVisitNum Latest Version: 4.1 Latest Version Save Date: 2018-05-21

Purpose

What does this plugin do? The getVisitNum Plugin returns the visit number for all visitors that come to the site within a specific time period (e.g. "x" number of days)

Why should I use this plugin? You should use the getVisitNum plugin if you want to track the visit number for any/all visitor(s) for the current week, the current month, the current year, or within the last “x” number of days.

Why shouldn't I use this plugin? You should not use the getVisitNum plugin to if you want to track the overall visit number for any/all visitor(s) for all time. Adobe Analytics already provides an out-of-the-box visit number dimension that would provide more accurate data for overall visit number data than this plugin-based solution.

Prerequisites You must have the following to run this plugin:

• AppMeasurement (i.e. the base Adobe Analytics Code) • The endOfDatePeriod plugin (included with code below)

Page 127: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

127 | Common Analytics Plugin Extension v2.1.2

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code to your AppMeasurement file will help Adobe Consulting with troubleshooting any potential issues with your implementation.

Run the getVisitNum function as needed within the doPlugins function - see the sample calls below.

Arguments to Pass In rp (optional, integer OR string):

• Set the rp argument equal to the number of days before the visit number counter resets. Defaults to 365 (i.e. 1 year) when not set

• When rp is set equal to "w", the visit number counter resets at the end of the week (i.e. This Saturday at 11:59 PM)

• When rp is set equal to "m", the visit number counter resets at the end of the month (i.e. the 28th/30th/31st of the month)

• When rp is set equal to "y", the visit number counter resets at the end of the year (i.e. December 31st)

erp (optional, boolean):

• When the rp argument is equal to a number, the erp argument determines whether the number of days before the visit number counter resets should be extended by "rp" number of days when a visitor returns to the site. Defaults to true when the rp argument is equal to a number

Returns The getVisitNum Plugin will return a visitor’s current visit number, the value of which is dependent on the settings in the getVisitNum call.

For instance, if a visitor had been to the site 5 times during the current month but only 2 times during the current week:

• A call to getVisitNum where the "rp" argument is equal to "w" would return the value of 2 during the visitor's latest visit to the site

• A call to getVisitNum where the "rp" argument is equal to "m" would return the value of 5 during the visitor's latest visit to the site

The visit number will increment any time the visitor returns to your site after 30 minutes of inactivity.

Page 128: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

128 | Common Analytics Plugin Extension v2.1.2

Cookies The getVisitNum Plugin sets a cookie called "s_vnc[LENGTH]" where [LENGTH] is the value passed into the rp parameter (e.g. "s_vncw", "s_vncm", "s_vnc365", etc.). The value of the cookie is equal to a combination of a unix timestamp that represents the time that the visit number will reset (e.g. end of the week, end of the month, after 365 days of inactivity, etc.) AND the visit number.

The plugin sets another cookie, called "s_ivc", that is equal to only to the value of "true" and expires after 30 minutes of inactivity (i.e. at the end of the visit).

Example Calls

Example #1 For a visitor that hasn't been to the site within the last 365 days, the following code will set s.prop1 equal to the value of 1:

s.prop1=s.getVisitNum();

Example #2 For a visitor that returns to the site within 364 days after his/her first visit, the following code will set s.prop1 equal to 2:

s.prop1=s.getVisitNum(365); If this visitor returns to the site within 364 days after his/her second visit, the following code will set s.prop1 equal to 3:

s.prop1=s.getVisitNum(365);

Page 129: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

129 | Common Analytics Plugin Extension v2.1.2

Example #3 For a visitor that returns to the site within 179 days after his/her first visit, the following code will set s.prop1 equal to 2:

s.prop1=s.getVisitNum(180,false); However, if this visitor returns to the site 1 or more days after his/her second visit, the following code will set s.prop1 equal to 1:

s.prop1=s.getVisitNum(180,false); When the second argument in the call is equal to false, the routine that determines when the visit number should be "reset" to 1 will do so "x" number of days – in this example, 365 days – after the visitor's first visit to the site.

When the second argument is equal to true (or not set at all), the plugin will reset the visit number to 1 only after "x" number of days – again, in this example, 365 days – of visitor inactivity.

Example #4 For all visitors that come to the site for the first time during the current week – beginning on Sunday - the following code will set s.prop1 equal to 1:

s.prop1=s.getVisitNum("w");

Example #5 For all visitors that come to the site for the first time during the current month – beginning on the first day of each month - the following code will set s.prop1 equal to 1:

s.prop1=s.getVisitNum("m"); Keep in mind that the getVisitNum plugin does not consider retail-based calendars. In other words, the plugin does not support calendar configurations like 4-5-4, 4-4-5, etc.

Example #6 For all visitors that come to the site for the first time during the current year – beginning on January 1 - the following code will set s.prop1 equal to 1:

s.prop1=s.getVisitNum("y");

Example #7 If you wish to track a visitor's visit number for the week, a visitor's visit number for the month, and a visitor's visit number for the year – all within different Analytics variables – you should use code that resembles the following:

s.prop1=s.getVisitNum("w"); s.prop2=s.getVisitNum("m"); s.prop3=s.getVisitNum("y"); In this case, the plugin will create three different cookies – one for each of the different time periods – to keep track of the individual visit number per time period.

Page 130: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

130 | Common Analytics Plugin Extension v2.1.2

S Object Replacement

When instantiating the main AppMeasurement library object with a name other than "s": Change the following portion of the plugin code from this…

s.getVisitNum=function(rp,erp)

…to this:

[objectname].getVisitNum=function(rp,erp)

You will need to modify the the isInteger, endOfDatePeriod and daysInMonth plugins in a similar fashion

Page 131: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

131 | Common Analytics Plugin Extension v2.1.2

Version History

4.1 (2018-05-21)

• Updated to accommodate version 1.1 of the endOfDatePeriod plugin

4.0 (2018-04-17)

• Point Release (recompiled, smaller code size) • Removed the cookie arguments as the plugin will now dynamically generate cookies based off of

the time period (the "rp" argument)

3.0 (2016-06-05)

• Complete overhaul • Combined all previous solutions available in sundry getVisitNum plugin variations into one single

plugin. Note: Changes to versions before 3.0 are undocumented

Return to Table of Contents

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: getVisitNum v4.1 (Requires AppMeasurement and the endOfDatePeriod plugin) */ s.getVisitNum=function(rp,erp){var s=this,c=function(rp){return isNaN(rp)?!1:(parseFloat(rp)|0)===parseFloat(rp)};rp=rp?rp:365; erp=erp?!!erp:c(rp)?!0:!1;if("boolean"===typeof erp){var f=(new Date).getTime(),b=endOfDatePeriod(rp);if(s.c_r("s_vnc"+rp))var g=s.c_r("s_vnc"+rp).split("&vn="),d=g[1];if(s.c_r("s_ivc"))return d?(b.setTime(f+18E5),s.c_w("s_ivc",!0,b),d):"unknown visit number";if("undefined"!==typeof d)return d++,c=erp&&c(rp)?f+864E5*rp:g[0],b.setTime(c),s.c_w("s_vnc"+rp,c+"&vn="+d,b), b.setTime(f+18E5),s.c_w("s_ivc",!0,b),d;c=c(rp)?f+864E5*rp:endOfDatePeriod(rp).getTime();s.c_w("s_vnc"+rp,c+"&vn=1",b);b.setTime(f+18E5);s.c_w("s_ivc",!0,b);return"1"}}; /* Adobe Consulting Plugin: endOfDatePeriod v1.1 (No Prerequisites Needed) */ var endOfDatePeriod=function(dp){var a=new Date,b=isNaN(dp)?0:Math.floor(dp);a.setHours(23);a.setMinutes(59);a.setSeconds(59); "w"===dp&&(b=6-a.getDay());if("m"===dp){b=a.getMonth()+1;var d=a.getFullYear();b=(new Date(d?d:1970,b?b:1,0)).getDate()-a.getDate()}a.setDate(a.getDate()+b);"y"===dp&&(a.setMonth(11),a.setDate(31));return a}; /******************************************** END CODE TO DEPLOY ********************************************/

Page 132: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

132 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin – inList

General Details

Plugin Name: inList Latest Version: 2.1 Latest Version Save Date: 2019-09-24

Purpose

What does this plugin do? The inList plugin is a utility that allows you to check whether a value already exists within either a delimited list of values or a JavaScript array object.

Why should I use this plugin? You should use the inList plugin in conjunction with other plugins, such as the appendToList plugin, or if you want to simply check (within an if statement) whether a value already exists within a delimited list of values.

Why shouldn't I use this plugin? If you are looking for only a partial match between a specific value and a delimited list of values, then then you have no need for this plugin and can use a simple concatenation operator instead.

For example, if …

s.events='event1,event25,event3';

…and you want to find out if 'event2' is contained within s.events (without an exact match), then the following if statement…

if(s.events.indexOf('event2') >- 1)

…will suffice, as it will return a positive number and thus indicate the fact that event2 is contained within s.events (as a "partial match" with event25)

Prerequisites None, although the function as provided in the code below is designed to be attached to the AppMeasurement (i.e. the base Adobe Analytics Code) object

How to Implement

Page 133: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

133 | Common Analytics Plugin Extension v2.1.2

If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code to your AppMeasurement file will help Adobe Consulting with troubleshooting any specific/future problems with the implementation.

Run the inList function as needed within the doPlugins function (see sample calls below)

Arguments to Pass In lv (required, string or array): The delimited list of values or JavaScript array object that might contain the lookup value specified in the vtc argument

vtc (required, string): the value to check for within the values specified in the lv argument

d: (optional, string) The delimiter used to separate out the individual values contained in the lv argument. Defaults to a comma (i.e. ",") when not set

cc: (optional, boolean) A flag that determines whether a case-sensitive check will be used to determine whether the vtc argument value already exists in the lv argument value

• If cc equals true, then a case-sensitive check will be made for the value (vtc argument) you want to look for within the lv argument

• If cc is not set (or is equal to false), then a case-insensitive check will be made for the value you want to look for within the lv argument

Returns

• The inList plugin returns "true" (boolean) if it finds an exact match between the vtc argument's value and any of the values contained within the lv argument.

• Otherwise, the plugin returns "false" (boolean)

Cookies The inList plugin does not set any cookies.

Example Calls

Example #1

Page 134: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

134 | Common Analytics Plugin Extension v2.1.2

If… s.events="event22,event24";

…and the following code runs… if(s.inList(s.events,"event22")) …the conditional if statement will be true

Example #2

If… s.events="event22,event24";

…and the following code runs… if(s.inList(s.events,"event2")) …the conditional if statement will be false because the inList call did not make an exact match between event2 and either of the delimited-values in s.events

Page 135: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

135 | Common Analytics Plugin Extension v2.1.2

Example #3

If… s.events="event22,event24";

…and the following code runs… if(!s.inList(s.events,"event23")) …the conditional if statement will be true because the inList call did not make an exact match between event23 and either of the delimited-values in s.events (notice the "NOT" operator at the beginning of the inList variable call).

Example #4

If… s.events = "event22,event23";

…and the following code runs… if(s.inList(s.events,"EVenT23","",1)) …the conditional if statement will be false. Although this example isn't practical, it demonstrates the need to use caution when using the case sensitive flag.

Example #5

If… s.linkTrackVars = "events,eVar1";

…and the following code runs… if(s.inList(s.linkTrackVars,"eVar1","|")) …the conditional if statement will be false. The value of the d argument passed into the call (i.e. "|") assumes that the individual values in s.linkTrackVars are delimited by a pipe character, whereas in reality, the values are delimited by a comma. Hence, a match will try to be made between the whole value of s.linkTrackVars (i.e. "events,eVar1") and the value to look for (i.e. "eVar1").

Page 136: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

136 | Common Analytics Plugin Extension v2.1.2

S Object Replacement

When instantiating the main AppMeasurement library object with a name other than "s", change the following portion of the plugin code from this…

s.inList=function(lv,vtc,d,cc)

…to this:

[objectname].inList=function(lv,vtc,d,cc)

Version History

v2.0 (2018-04-17)

• Point Release (recompiled, smaller code size)

v1.01 (2017-09-27)

• JavaScript code optimizations to reduce size (no functionality changes)

1.0 (2009)

• Initial Release

Return to Table of Contents

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: inList v2.1 (Requires AppMeasurement) */ s.inList=function(lv,vtc,d,cc){if("string"!==typeof vtc)return!1;if("string"===typeof lv)lv=lv.split(d||",");else if("object"!== typeof lv)return!1;d=0;for(var e=lv.length;d<e;d++)if(1==cc&&vtc===lv[d]||vtc.toLowerCase()===lv[d].toLowerCase())return!0;return!1}; /******************************************** END CODE TO DEPLOY ********************************************/

Page 137: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

137 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin – manageVars

General Details

Plugin Name: manageVars Latest Version: v2.1 Latest Version Save Date: 2019-01-14

Purpose of This Plugin

What does this plugin do? The manageVars plugin allows you to manipulate the values of multiple Adobe Analytics variables at one time; this version includes specific functionality to lowercase or remove unnecessary characters from multiple variable values at the same time.

Why should I use this plugin? You should use the manageVars plugin if you want to easily lowercase or "clean up" the value of multiple Analytics variable values at one time.

Why shouldn't I use this plugin? You won't need to use the manageVars plugin if you don't need to manipulate the values of multiple Analytics variables at the same time

Prerequisites You must have AppMeasurement (i.e. the base Adobe Analytics Code) and the pt plugin to run the manageVars plugin. However, the manageVars plugin is useless without additional functions that the plugin can call to manipulate multiple variables at the same time; hence, this version includes two "starter" functions that allow you to both lowercase and "clean" multiple variable values at the same time. The plugin can be "expanded" by creating new functions designed to manipulate multiple variables at the same time.

Page 138: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

138 | Common Analytics Plugin Extension v2.1.2

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code to the AppMeasurement file will help Adobe Consulting with troubleshooting any potential implementation issues.

Run the manageVars function as needed within the doPlugins function (see example calls below)

Arguments to Pass In cb (required, string): The name of a callback function that the plugin will call to manipulate the Adobe Analytics variables. This version of the plugin includes the "lowerCaseVars" and the "cleanStr" callback functions

lv (optional, string): A comma-delimited list of the Adobe Analytics variables that you want to manipulate (or explicitly NOT manipulate per the "il" argument value); defaults to ALL Adobe Analytics variables when not set. "ALL" Adobe Analytics variables include the following:

• pageName • purchaseID • channel • server • pageType • campaign • state • zip • events • products • transactionID • prop1 – prop75 • eVar1 – eVar250 • hier1 – hier5 • list1 – list3 • All contextData variables

Il (optional, boolean): Set equal to false if you want to exclude the list of variables declared in the lv argument from being manipulated by the callback function; defaults to true

Page 139: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

139 | Common Analytics Plugin Extension v2.1.2

Returns The manageVars plugin returns nothing, per se, but changes the values of all Adobe Analytics variables per the callback function and the other arguments passed into the variable

Cookies The manageVars plugin does not create or use any cookies

Example Calls

Example #1

The following code…

s.manageVars("lowerCaseVars");

…changes the values of all the variables described above to lowercased versions. The sole exception to this is the events variable, as some of the events (e.g. scAdd, scCheckout, etc.) are case-sensitive and should not be lowercased

Example #2 The following code…

s.manageVars("lowerCaseVars", "events", false);

…essentially produces the exact same result as the first example since the events variable isn't lowercased by default.

Page 140: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

140 | Common Analytics Plugin Extension v2.1.2

Example #3 The following code…

s.manageVars("lowerCaseVars", "eVar1,eVar2,eVar3,list2");

…will change (e.g. lowercase) only the values of eVar1, eVar2, eVar3, and list2

Example #4 The following code…

s.manageVars("lowerCaseVars", "eVar1,eVar2,eVar3,list2", false);

…will change (e.g. lowercase) the values of all the variables described above EXCEPT for eVar1, eVar2, eVar3, and list2

Example #5 The following code…

s.manageVars("cleanStr");

…changes the values of all the variables described above, including the events variables. Specifically, the cleanStr callback function does the following to each variables' value:

• Removes HTML encoding • Removes whitespaces found at the beginning and end of the value • Replaces left/right single quotes (e.g. ’) with a straight single quote (') • Replaces tab characters, newline characters, and carriage return characters with spaces • Replaces all double (or triple, etc.) spaces with single spaces

Page 141: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

141 | Common Analytics Plugin Extension v2.1.2

S Object Replacement

When instantiating the main AppMeasurement library object with a name other than "s", change the following portion of the plugin code from this…

s.manageVars=function(cb,lv,il)

…to this:

[objectname].manageVars=function(cb,lv,il)

Also be sure to change this…

s.lowerCaseVars=function(v)

…to this:

[objectname].lowerCaseVars=function(v)

And change this…

s.cleanStr=function(b)

…to this:

[objectname].cleanStr=function(b)

And (finally) change this…

s.pt=function(lv,de,cf,fa)

…to this:

[objectname].pt=function(lv,de,cf,fa)

Page 142: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

142 | Common Analytics Plugin Extension v2.1.2

Version History

2.01 (2019-01-14)

• Bug fix for Internet Explorer 11 Browsers

2.0 (2018-05-07) (previous changes undocumented)

• Point release (including complete reanalysis/rewrite of plugin) • Added cleanStr callback function

Return to Table of Contents

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: manageVars v2.01(Requires AppMeasurement; Also requires pt plugin and other callback function/plugins) */ s.manageVars=function(cb,lv,il){var s=this;if(!s[cb])return!1;lv="string"===typeof lv?lv:"";il="undefined"!==typeof il?il:!0;var a,d="pageName,purchaseID,channel,server,pageType,campaign,state,zip,events,products,transactionID";for(a=1;76>a;a++)d+=",prop"+a;for(a=1;251>a;a++)d+=",eVar"+a;for(a=1;6>a;a++)d+=",hier"+a;for(a=1;4>a;a++)d+=",list"+a;for(a in s.contextData)d+= ",contextData."+a;if(lv){if(1==il)d=lv.replace("['",".").replace("']","");else if(0==il){lv=lv.split(",");il=d.split(",");d="";for(x in lv)for(y in"string"===typeof lv[x]&&-1<lv[x].indexOf("contextData")&&(lv[x]="contextData."+lv[x].split("'")[1]),il)lv[x]===il[y] &&(il[y]="");for(y in il)d+=il[y]?","+il[y]:""}s.pt(d,",",cb,0);return!0}return""===lv&&il?(s.pt(d,",",cb,0),!0):!1}; /* Adobe Consulting Plugin: lowerCaseVars for manageVars (Requires AppMeasurement; Also Requires the manageVars plugin) */ s.lowerCaseVars=function(v){var s=this;s[v]&&"events"!==v&&-1===v.indexOf("contextData")?(s[v]=s[v].toString(),0!== s[v].indexOf("D=")&&(s[v]=s[v].toLowerCase())):-1<v.indexOf("contextData")&&(v=v.substring(v.indexOf(".")+1), s.contextData[v]&&(s.contextData[v]=s.contextData[v].toString(),s.contextData[v]=s.contextData[v].toLowerCase()))}; /* Adobe Consulting Plugin: cleanStr for manageVars (Requires AppMeasurement; Also Requires the manageVars plugin) */ s.cleanStr=function(b){var s=this,c=function(a){if("string"===typeof a){a=a.replace(/<\/?[^>]+(>|$)/g,"");a= a.replace(/^\s+|\s+$/g,"");a=a.replace(/[\u2018\u2019\u201A]/g,"'");a=a.replace(/\t+/g,"");for(a=a.replace(/[\n\r]/g," ");-1<a.indexOf(" ");)a=a.replace(/\s\s/g," ");return a}return""};s[b]&&0>b.indexOf("contextData")?s[b]=c(s[b]):-1<b.indexOf("contextData")&&(b=b.substring(b.indexOf(".")+1),s.contextData[b]&&(s.contextData[b]=c(s.contextData[b])))};

Page 143: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

143 | Common Analytics Plugin Extension v2.1.2

/* Adobe Consulting Plugin: pt v2.0 (Requires AppMeasurement) */ s.pt=function(lv,de,cf,fa){if(!lv||!de||!this[cf])return"";lv=lv.split(de?de:",");de=lv.length;for(var e="",c=0;c<de&&!(e= this[cf](lv[c],fa));c++);return e}; /******************************************** END CODE TO DEPLOY ********************************************/

Page 144: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

144 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin – Numbers Suite

General Details

Plugin Name: Numbers Suite Latest Version: v1.0 Latest Version Save Date: 2019-10-07

Purpose of This Plugin

What does this plugin do? The Numbers Suite a series of JavaScript functions that allow you to…

• Add a specific number of zeroes to the beginning of a number (if a number is required to have a certain number of digits in it)

• Generate a random number with a specific number of digits • Round a number to the closet hundredth (for currency purposes)

Why should I use this plugin? You should use the Numbers Suite plugins if, for example..

• You work with JavaScript date objects and need to make sure that you format a date's month and day with two digits instead of just one digit (e.g. "01/09/2020" instead of just "1/9/2020"

• You deploy 3rd-party tags and need to generate a cache-busting random number • You need to capture currency-based values in Adobe Analytics variables but need the values to

be rounded to a proper amount

Prerequisites None

Page 145: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

145 | Common Analytics Plugin Extension v2.1.2

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code will help Adobe Consulting with troubleshooting any potential implementation issues.

• Save the code, save the rule, and then Approve and Publish the rule Via other means:

Copy/paste the code either into a .js file or within an HTML <script> tag that you mean to deploy on your site

• Run the Numbers Suite functions as needed within the doPlugins function (see example calls below)

Arguments to Pass In For the zeroPad function:

• num (required, integer): A whole number to pad (i.e. add zeroes to the beginning per the nod argument's value). The code will round down the value of this argument if it contains decimals

• nod (required, integer): The number of digits to be contained in the final return value. If the number to pad has less digits than the number of digits to pad to, then the plugin will add enough zeroes to the beginning of the "num" argument value to ensure it has the appropriate number of digits

For the randomNumber function:

• nod (optional, integer), the number of digits in the random number that you want to generate. Max value is 17 digits, defaults to 10 digits

For the twoDecimals function:

• val (required, number), a number (represented by either a string or number object) that you want to round to the nearest hundredth

Returns

• The zeroPad function returns a string equal to the "num" argument but with a specific number of zeroes added to the beginning of its value, which will ensure the return value will have the correct number of digits per the "nod" argument

Page 146: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

146 | Common Analytics Plugin Extension v2.1.2

• The randomNumber function returns a string equal to a random number with the number of digits specified in the "nod" argument

• The twoDecimals function returns a number object (e.g. float, integer, etc.) rounded to the closest hundredth

Cookies The Numbers Suite plugins do not create or use any cookies

Example Calls

zeroPad examples

s.eVar25 = zeroPad(25.5562, 5) //sets eVar25 equal to "00025" s.prop1 = zeroPad(25, 1) //sets prop1 equal to "25" s.prop1 = zeroPad(232425235,23) //sets prop1 equal to "00000000000000232425235"

randomNumber examples

s.eVar65 = randomNumber(15) //sets eVar65 equal to "721759731750342" or some other random 15-digit number randomNumber() //returns a random 10-digit number but is useless since this isn't used in an expression var j = randomNumber(35) //sets a variable named j equal to "15476068651810060" or another random 17-digit number

twoDecimals examples

s.events = "event10=" + twoDecimals("85.4827128694") //sets s.events="event10=85.48" var fivehundredthirtytwo = twoDecimals(532.000000001) //sets the variable fivehundredthirtytwo equal to 532 s.eVar65 = twoDecimals("672132.9699736457") //sets s.eVar65 equal to 672132.97

Version History

1.0 (2015-05-25)

Page 147: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

147 | Common Analytics Plugin Extension v2.1.2

• Initial Release (zeroPad v1.0 was provided previously in a separate document)

Return to Table of Contents

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: zeroPad v1.0 (No Prerequisites) */ function zeroPad(num,nod){num=parseInt(num);nod=parseInt(nod);if(isNaN(num)||isNaN(nod))return"";var c=nod-num.toString().length+ 1;return Array(+(0<c&&c)).join("0")+num}; /* Adobe Consulting Plugin: randomNumber v2.0 (zeroPad optional)*/ function randomNumber(nod){nod="number"===typeof nod?17>Math.abs(nod)?Math.round(Math.abs(nod)):17:10;for(var a="1",c=0;c<nod;c++) a+="0";a=Number(a);a=Math.floor(Math.random().toFixed(nod)*a)+"";a.length!==nod&&"undefined"!==typeof zeroPad&&(a=zeroPad(a,nod)); return a}; /* Adobe Consulting Plugin: twoDecimals v1.0 (No Prerequisites)*/ function twoDecimals(v){return"undefined"===typeof v||void 0===v||isNaN(v)?0:Number(Number(v).toFixed(2))}; /******************************************** END CODE TO DEPLOY ********************************************/

Page 148: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

148 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin - pt

General Details

Plugin Name: pt Latest Version: 2.0 Latest Version Save Date: 2018-04-17

Purpose

What does this plugin do? The pt plugin executes a function on a list of Adobe Analytics variables.

For example, the following function will run the clearVars function three times, once using eVar1 as the argument, once using eVar4 as the argument, and once using eVar29 as the argument. The end result clear out the values of eVar1, eVar4 and eVar29

s.pt('eVar1,eVar4,eVar29', ',', 'clearVars');

Why should I use this plugin? In and of itself, there might not be a need to use this plugin. However, several other Adobe Consulting plugins, including getQueryParam, require this plugin as they work with multiple parameters and variables at the same time.

Why shouldn't I use this plugin? Do not use this plugin if you have no need to run a specific function on more than one Analytics variable at a time

Page 149: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

149 | Common Analytics Plugin Extension v2.1.2

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code to your AppMeasurement file will help Adobe Consulting with troubleshooting any potential issues with your implementation.

Run the pt function as needed within the doPlugins function (see sample calls below)

Arguments to Pass In lv (required, string): A list of Adobe Analytics variables (or other JavaScript variables) that the function contained in the "cf" argument can execute against.

de (optional, string): The delimiter that separates the list of variables in the "lv" argument; defaults to a comma (",") character.

cf (required, string): The name of the callback function (contained in the AppMeasurement Object) to be called against each of the variables contained in the "lv" argument.

fa (optional, string): If the function in the "cf" argument calls for additional arguments when it runs, include them here; defaults to undefined

Returns The pt plugin will return a value if the callback function ("cf" argument) returns a value

Cookies The pt plugin by itself does not create any cookies. However, the callback function specified in the cf argument might create cookies depending on its functionality.

Page 150: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

150 | Common Analytics Plugin Extension v2.1.2

Example Calls

Example #1

The following code is part of the getQueryParam plugin. It runs the getParameterValue helper function against each of the key-value pairs that are contained in the URL's querystring (fullQueryString). In other to extract each key-value pair, the fullQueryString must be delimited and split out by an ampersand "&" character. The parameterKey refers to the query string parameter that the plugin is specifically trying to extract from the query string returnValue = s.pt(fullQueryString, "&", "getParameterValue", parameterKey) In essence, the above line is a shortcut for running code that resembles the following:

var returnValue = "", parameters = fullQueryString.split("&"), parametersLength = parameters.length; for(var i=0; i < parametersLength; i++) { returnValue = s.getParameterValue(parameters[i], parameterKey); if returnValue !== "" break; }

S Object Replacement

When instantiating the main AppMeasurement library object with a name other than "s", change the following portion of the plugin code from this… s.pt=function(lv,de,cf,fa)

…to this: [newobjectname].pt=function(lv,de,cf,fa)

Page 151: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

151 | Common Analytics Plugin Extension v2.1.2

Version History

2.0 (2018-04-17)

• Point Release (recompiled, smaller code size) • Added Support for both the H-code and AppMeasurement versions of the Adobe Analytics

javascript library.

1.0 (23 September 2013)

• Initial version

Return to Table of Contents

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: pt v2.0 (Requires AppMeasurement) */ s.pt=function(lv,de,cf,fa){if(!lv||!de||!this[cf])return"";lv=lv.split(de?de:",");de=lv.length;for(var e="",c=0;c<de&&!(e=this[cf](lv[c],fa));c++);return e}; /******************************************** END CODE TO DEPLOY ********************************************/

Page 152: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

152 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin - removeFromList

General Details

Plugin Name: rfl (removeFromList) Latest Version: 2.0 Latest Version Save Date: 2018-04-16

Purpose

What does this plugin do? The rfl plugin is a utility that allows you to "safely" remove values from list-delimited variables (e.g. s.events, s.linkTrackVars, listVars, etc.).

Why should I use this plugin? You should use the rfl plugin if you want to remove a specific value from a variable that already contains multiple delimited values. This plugin utility is especially useful for removing specific events (contained in s.events) that use serialization and/or integer/currency-based syntax.

• If the value you want to remove exists in the variable that you want to remove the value from, then the plugin will keep everything in the variable except for the value to remove.

• If the value you want to remove doesn't exist in the variable, then the code will simply keep the original variable value as is.

You can use the plugin if you want to also change the delimiter that a variable uses to separate out the individual values contained within it.

Why shouldn't I use this plugin? If you have no need to remove a specific value from a variable containing a delimited list of values, then you have no need for this plugin.

Prerequisites You must have AppMeasurement (i.e. the base Adobe Analytics Code) to run this plugin.

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

Page 153: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

153 | Common Analytics Plugin Extension v2.1.2

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code to your AppMeasurement file will help Adobe Consulting with troubleshooting any potential issues with your implementation.

Run the rfl plugin as needed within the doPlugins function (see sample calls below)

Arguments to Pass in lv: A variable (or string) that is equal to a list of delimited values

vr: A single value that will be removed from the lv argument's delimited list. Trying to remove multiple values during a single rfl call is not recommended (see examples #12/#13 below)

d1: (OPTIONAL) The delimiter that separates out the individual values contained in the lv argument. Defaults to a comma (i.e. ",") when not set

d2: (OPTIONAL) The delimiter that will separate the remaining (i.e. final) list of values after the value contained in the vr argument has been removed from the lv argument's value. Defaults to the same value as the d1 argument

df: (OPTIONAL) A "flag" that, when set equal to true, will force the plugin to remove only duplicate instances of the vr argument value from the lv argument rather than all instances. Defaults to false when not set

Returns The rfl plugin returns the value of the lv argument but without any instances (or duplicate instances) of the value specified in the vr argument

Cookies The rfl plugin does not create any cookies

Page 154: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

154 | Common Analytics Plugin Extension v2.1.2

Example Calls

Example #1 If…

s.events = "event22,event24,event25"; …and the following code runs…

s.events = s.rfl(s.events,"event24"); …the final value of s.events will be:

s.events = "event22,event25";

Example #2 If…

s.events = "event22,event24,event25"; …and the following code runs…

s.events = s.rfl(s.events,"event26"); … the final value of s.events will be:

s.events = "event22,event24,event25"; In this example, the rfl call made no changes to s.events since s.events didn't contain "event26"

Page 155: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

155 | Common Analytics Plugin Extension v2.1.2

Example #3 If…

s.events = "event22,event24,event25"; …and the following code runs…

s.events = s.rfl (s.events); … the final value of s.events will be:

s.events = ""; If either the lv argument or vr argument are blank in an s.rfl call, then the plugin will return nothing

Example #4 If…

s.prop4 = "hello|people|today"; …and the following code runs…

s.eVar5 = s.rfl(s.prop4,"people","|"); … the final value of s.prop4 will still be…

s.prop4 = "hello|people|today"; …but the final value of s.eVar5 will be:

s.eVar5 = "hello|today"; Keep in mind that the plugin only returns a value; it does not actually "reset" the variable passed in through the lv argument.

Page 156: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

156 | Common Analytics Plugin Extension v2.1.2

Example #5

If… s.prop4 = "hello|people|today";

…and the following code runs… s.prop4 = s.rfl(s.prop4,"people");

… the final value of s.prop4 will still be… s.prop4 = "hello|people|today"; Be sure to set the d1 argument in cases where the lv argument value contains a different delimiter than the default value (i.e. comma).

Example #6 If…

s.events = "event22,event23,event25"; …and the following code runs…

s.events = s.rfl(s.events,"EVenT23"); … the final value of s.events will be:

s.events = "event22,event23,event25"; Although this example isn't practical, it demonstrates the need to pass in case-sensitive values.

Page 157: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

157 | Common Analytics Plugin Extension v2.1.2

Example #7 If…

s.events = "event22,event23:12345,event25"; …and the following code runs…

s.events = s.rfl(s.events,"event23"); … the final value of s.events will be:

s.events = "event22,event25";

Example #8 If…

s.events = "event22,event23:12345,event25"; …and the following code runs…

s.events = s.rfl(s.events,"event23:12345"); … the final value of s.events will be:

s.events = "event22,event23:12345,event25"; When you need to remove an event that uses serialization and/or numeric/currency syntax, you should specify only the event itself (i.e. without the serialization/numeric/currency values) in the s.rfl call.

Page 158: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

158 | Common Analytics Plugin Extension v2.1.2

Example #9 If…

s.events = "event22,event23,event23,event23,event24,event25"; …and the following code runs…

s.events = s.rfl(s.events,"event23"); … the final value of s.events will be:

s.events = "event22,event24,event25");

Example #10 If…

s.events = "event22,event23,event23,event23,event24,event25"; …and the following code runs…

s.events = s.rfl(s.events,"event23", "", "",true); … the final value of s.events will be:

s.events = "event22,event23,event24,event25");

Example #11 If…

s.events = "event22,event23,event23,event23,event24,event25"; …and the following code runs…

s.events = s.rfl(s.events,"event23", "", "|",true); … the final value of s.events will be:

s.events = "event22|event23|event24|event25");

Example #12 If…

s.events = "event22,event23,event24,event25"; …and the following code runs…

s.events = s.rfl(s.events,"event23,event24"); … the final value of s.events will be:

s.events = "event22,event23,event24,event25"; Setting multiple values in the vr argument is not supported. The rfl logic in the above example would first split out the values in the lv argument (i.e. s.events) then try to match each delimited value to the complete vr argument value (i.e. "event23,event24").

Example #13 If…

Page 159: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

159 | Common Analytics Plugin Extension v2.1.2

s.events = "event22,event23,event24,event25"; …and the following code runs…

s.events = s.rfl(s.events,"event23"); s.events = s.rfl(s.events,"event24"); … the final value of s.events will be:

s.events = "event22,event25"); Each value to be removed from the list should be contained within its own s.rfl call.

Page 160: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

160 | Common Analytics Plugin Extension v2.1.2

Example #14 If…

s.linkTrackVars = "events,eVar1,eVar2,eVar3"; …and the following code runs…

s.linkTrackVars = s.rfl(s.linkTrackVars,"eVar2", ",", ",", false); … the final value of s.linkTrackVars will be:

s.linkTrackVars = "events,eVar1,eVar3"; The last three arguments (i.e. ",",",",false) at the end of this s.rfl call are not necessary but are also not "hurting anything" by being there since they match the default settings.

Example #15 If…

s.events = "event22,event23,event24"; …and the following code runs…

s.rfl(s.events,"event23"); … the final value of s.events will still be:

s.events = "event22,event23,event24"; Again, keep in mind the plugin only returns a value; it does not actually "reset" the variable passed in through the lv argument.

Page 161: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

161 | Common Analytics Plugin Extension v2.1.2

S Object Replacement

When instantiating the main AppMeasurement library object with a name other than "s", change the following portion of the plugin code from this… s.rfl=function(l,v,d1,d2,df)

…to this: [objectname].rfl=function(l,v,d1,d2,df) NOTE: If you want to continue using the older name of the plugin ("rfl"), you may also change the beginning part of the code to this…

s.rfl=function(l,v,d1,d2,df)

…or this:

[objectname].rfl=function(l,v,d1,d2,df)

etc.

Version History

2.0 (2018-04-16)

• Point release (recompiled, smaller code size) • Removed the need for the join plugin

1.0 (2016-07-18)

• "Official" first release (although has been in circulation for a long time)

Return to Table of Contents

Page 162: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

162 | Common Analytics Plugin Extension v2.1.2

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: rfl (removeFromList) v2.0 (Requires AppMeasurement) */ s.rfl=function(lv,vr,d1,d2,df){if(!lv||!vr)return"";var d=[],b="";d2=d2?d2:d1;df=df?!0:!1;lv=lv.split(d1?d1:",");d1=lv.length;for(var c=0;c<d1;c++)-1<lv[c].indexOf(":")&&(b=lv[c].split(":"),b[1]=b[0]+":"+b[1],lv[c]=b[0]),-1<lv[c].indexOf("=")&&(b=lv[c].split("="), b[1]=b[0]+"="+b[1],lv[c]=b[0]),lv[c]!==vr&&b?d.push(b[1]):lv[c]!==vr?d.push(lv[c]):lv[c]===vr&&df&&(b?d.push(b[1]):d.push(lv[c]),df=!1),b="";return d.join(d2)}; /******************************************** END CODE TO DEPLOY ********************************************/

Page 163: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

163 | Common Analytics Plugin Extension v2.1.2

Adobe Consulting Plugin – getDaysSinceLastVisit – (Deprecated)

General Details

Plugin Name: getDaysSinceLastVisit Latest Version: v3.0 Latest Version Save Date: [2018-08-18] IMPORTANT: This plugin has been deprecated and is no longer maintained by Adobe Consulting Services. A newer version of this plugin named getTimeSinceLastVisit can be found above

Purpose of This Plugin

What does this plugin do? The getDaysSinceLastVisit plugin allows you to track how long a visitor has taken to return to your site .

Prerequisites You must have AppMeasurement (i.e. the base Adobe Analytics Code) to run the getDaysSinceLastVisit plugin

How to Implement If you're using Launch by Adobe as your Tag Manager, install the "Common Analytics Plugins" extension (v2.0+) into your Web Property and in the "Common Analytics Plugins - Initialize" action configuration page simply check this plugin.

If you're not using Launch by Adobe as your Tag Manager, copy+ Paste the code - see below - to anywhere within the Plugins section of the AppMeasurement code.

NOTE: Adding the cyan-highlighted comments/version numbers of the code to the AppMeasurement file will help Adobe Consulting with troubleshooting any potential implementation issues.

Run the getAndPersistValue function as needed within the doPlugins function (see example calls below)

Arguments to Pass In None

Page 164: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

164 | Common Analytics Plugin Extension v2.1.2

Returns The getDaysSinceLastVisit plugin returns one of the following values (on ONLY the first page of the visit)

• "New Visitor" • "Less than 1 day" • "Less than 7 days" • "More than 7 days" • "More than 30 days" • "More than a Year"

Cookies The getDaysSinceLastVisit plugin creates a cookie called "s_dslv" that is set equal a unix timestamp representing the current time. The cookie expires after two years of inactivity.

Example Calls

Example #1

If a brand new visitor comes to the site and the following code runs on the first page of the visit … s.prop1 = s.getDaysSinceLastVisit();

… the value of s.prop1 will be “New Visitor”. If, after 30 minutes of inactivity, the same code runs on the same domain, the value of s.prop1 will be “Less than 1 day”. If, after 4 days of further inactivity, the same code runs on the same domain, the value of s.prop1 will be “Less than 7 days”, etc.

S Object Replacement

When instantiating the main AppMeasurement library object with a name other than "s", change the following portion of the plugin code from this…

s.getDaysSinceLastVisit = function(

…to this:

[objectname].getDaysSinceLastVisit = function(

Page 165: Common Analytics Plugin Extension V2.1€¦ · 3 | Common Analytics Plugin Extension v2.1.2 Extension Overview The Common Analytics Plugin Extension v2.1.1 is an upgraded version

165 | Common Analytics Plugin Extension v2.1.2

Version History

3.0 (2018-04-16)

• Point Release (recompiled code, smaller size, etc.) • Changed return value for New Visitors/No Cookie to "New Visitor" • Added return value of "More than a Year"

2.0 (2016-03-23)

• Updates for AppMeasurement Compatibility

Return to Table of Contents

Code to Deploy This is only required if the “Common Analytics Plugins” extension for Launch by Adobe is not being used.

/******************************************* BEGIN CODE TO DEPLOY *******************************************/ /* Adobe Consulting Plugin: getDaysSinceLastVisit v3.0 (Requires AppMeasurement) */ s.getDaysSinceLastVisit=function(){var a=new Date,b=a.getTime(),c=this.c_r("s_dslv");a.setTime(b+63072E6);this.c_w("s_dslv",b,a); if(c){a=b-c;if(18E5<a){if(31536E6<a)return"More than a year";if(2592E6<a)return"More than 30 days";if(a<2592E6+1&&6048E5<a)return "More than 7 days";if(a<6048E5+1&&864E5<a)return"Less than 7 days";if(a<864E5+1)return"Less than 1 day"}return""}return"New Visitor"}; /******************************************** END CODE TO DEPLOY ********************************************/