From 9b2837d9fb7d4326008e93d52cd7c2be6cb1c7ac Mon Sep 17 00:00:00 2001 From: standy Date: Sat, 8 Apr 2017 15:04:39 +0300 Subject: [PATCH 01/13] Removed "underscore" dependency --- lib/index.js | 19 +++++++++---------- package.json | 1 - test/_enqueue.js | 1 - test/event.js | 1 - test/exception.js | 1 - test/index.js | 1 - test/item.js | 1 - test/middleware.js | 1 - test/pageview.js | 1 - test/send.js | 1 - test/set.js | 1 - test/timing.js | 1 - test/transaction.js | 1 - 13 files changed, 9 insertions(+), 22 deletions(-) diff --git a/lib/index.js b/lib/index.js index 91008de..3ed385e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,6 +1,5 @@ var async = require("async"); -var _ = require("underscore"); var request = require("request"); var uuid = require("uuid"); var querystring = require("querystring"); @@ -142,7 +141,7 @@ Visitor.prototype = { params = this._translateParams(params); - params = _.extend({}, this._persistentParams || {}, params); + params = Object.assign({}, this._persistentParams || {}, params); params.dp = path || params.dp || this._context.dp; params.dh = hostname || params.dh || this._context.dh; @@ -185,7 +184,7 @@ Visitor.prototype = { params = this._translateParams(params); - params = _.extend({}, this._persistentParams || {}, params); + params = Object.assign({}, this._persistentParams || {}, params); params.cd = screenName || params.cd || this._context.cd; params.an = appName || params.an || this._context.an; @@ -224,7 +223,7 @@ Visitor.prototype = { params = this._translateParams(params); - params = _.extend({}, this._persistentParams || {}, params); + params = Object.assign({}, this._persistentParams || {}, params); params.ec = category || params.ec || this._context.ec; params.ea = action || params.ea || this._context.ea; @@ -269,7 +268,7 @@ Visitor.prototype = { params = this._translateParams(params); - params = _.extend({}, this._persistentParams || {}, params); + params = Object.assign({}, this._persistentParams || {}, params); params.ti = transaction || params.ti || this._context.ti; params.tr = revenue || params.tr || this._context.tr; @@ -314,7 +313,7 @@ Visitor.prototype = { params = this._translateParams(params); - params = _.extend({}, this._persistentParams || {}, params); + params = Object.assign({}, this._persistentParams || {}, params); params.ip = price || params.ip || this._context.ip; params.iq = quantity || params.iq || this._context.iq; @@ -352,7 +351,7 @@ Visitor.prototype = { params = this._translateParams(params); - params = _.extend({}, this._persistentParams || {}, params); + params = Object.assign({}, this._persistentParams || {}, params); params.exd = description || params.exd || this._context.exd; params.exf = +!!(fatal || params.exf || this._context.exf); @@ -390,7 +389,7 @@ Visitor.prototype = { params = this._translateParams(params); - params = _.extend({}, this._persistentParams || {}, params); + params = Object.assign({}, this._persistentParams || {}, params); params.utc = category || params.utc || this._context.utc; params.utv = variable || params.utv || this._context.utv; @@ -432,7 +431,7 @@ Visitor.prototype = { self._log(count++ + ": " + JSON.stringify(params)); - var options = _.extend({}, self.options.requestOptions, { + var options = Object.assign({}, self.options.requestOptions, { body: getBody(params), headers: self.options.headers || {} }); @@ -456,7 +455,7 @@ Visitor.prototype = { params = this._translateParams(params) || {}; - _.extend(params, { + Object.assign(params, { v: config.protocolVersion, tid: this.tid, cid: this.cid, diff --git a/package.json b/package.json index 8b814a6..161a2e7 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,6 @@ "dependencies": { "async": "1.2.x", "request": "2.x", - "underscore": "1.x", "uuid": "^3.0.0" }, "devDependencies": { diff --git a/test/_enqueue.js b/test/_enqueue.js index a9a4feb..610feec 100644 --- a/test/_enqueue.js +++ b/test/_enqueue.js @@ -1,5 +1,4 @@ -var _ = require("underscore"); var request = require("request"); var qs = require("querystring"); var uuid = require("uuid"); diff --git a/test/event.js b/test/event.js index 63df9a0..e04f5be 100644 --- a/test/event.js +++ b/test/event.js @@ -1,5 +1,4 @@ -var _ = require("underscore"); var request = require("request"); var qs = require("querystring"); var uuid = require("uuid"); diff --git a/test/exception.js b/test/exception.js index b099c34..8a04fbd 100644 --- a/test/exception.js +++ b/test/exception.js @@ -1,5 +1,4 @@ -var _ = require("underscore"); var request = require("request"); var qs = require("querystring"); var uuid = require("uuid"); diff --git a/test/index.js b/test/index.js index 9b882a8..087a32a 100644 --- a/test/index.js +++ b/test/index.js @@ -1,5 +1,4 @@ -var _ = require("underscore"); var request = require("request"); var qs = require("querystring"); var uuid = require("uuid"); diff --git a/test/item.js b/test/item.js index 5348b0c..f855202 100644 --- a/test/item.js +++ b/test/item.js @@ -1,5 +1,4 @@ -var _ = require("underscore"); var request = require("request"); var qs = require("querystring"); var uuid = require("uuid"); diff --git a/test/middleware.js b/test/middleware.js index 09d8ccd..b76e091 100644 --- a/test/middleware.js +++ b/test/middleware.js @@ -1,5 +1,4 @@ -var _ = require("underscore"); var request = require("request"); var qs = require("querystring"); var uuid = require("uuid"); diff --git a/test/pageview.js b/test/pageview.js index 19e5956..b4915a1 100644 --- a/test/pageview.js +++ b/test/pageview.js @@ -1,5 +1,4 @@ -var _ = require("underscore"); var request = require("request"); var qs = require("querystring"); var uuid = require("uuid"); diff --git a/test/send.js b/test/send.js index 10d800f..ad10460 100644 --- a/test/send.js +++ b/test/send.js @@ -1,5 +1,4 @@ -var _ = require("underscore"); var request = require("request"); var qs = require("querystring"); var uuid = require("uuid"); diff --git a/test/set.js b/test/set.js index 268f929..afafd93 100644 --- a/test/set.js +++ b/test/set.js @@ -1,5 +1,4 @@ -var _ = require("underscore"); var request = require("request"); var qs = require("querystring"); var uuid = require("uuid"); diff --git a/test/timing.js b/test/timing.js index d4ec0b8..a29b3d2 100644 --- a/test/timing.js +++ b/test/timing.js @@ -1,5 +1,4 @@ -var _ = require("underscore"); var request = require("request"); var qs = require("querystring"); var uuid = require("uuid"); diff --git a/test/transaction.js b/test/transaction.js index 5554d42..cbf14f9 100644 --- a/test/transaction.js +++ b/test/transaction.js @@ -1,5 +1,4 @@ -var _ = require("underscore"); var request = require("request"); var qs = require("querystring"); var uuid = require("uuid"); From c85953a79da5d5f69b2f3f5992d774be184b7eb8 Mon Sep 17 00:00:00 2001 From: standy Date: Sat, 8 Apr 2017 15:37:38 +0300 Subject: [PATCH 02/13] Removed "async" dependency --- lib/index.js | 27 ++++++++++++++++----------- package.json | 1 - 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/index.js b/lib/index.js index 3ed385e..e8b2388 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,5 +1,4 @@ -var async = require("async"); var request = require("request"); var uuid = require("uuid"); var querystring = require("querystring"); @@ -408,15 +407,19 @@ Visitor.prototype = { var fn = fn || function () {}; self._log("Sending " + self._queue.length + " tracking call(s)"); - var test = function () { - return self._queue.length > 0; - } - var getBody = function(params) { return params.map(function(x) { return querystring.stringify(x); }).join("\n"); } - var iterator = function (fn) { + var onFinish = function (err) { + self._log("Finished sending tracking calls") + fn.call(self, err || null, count - 1); + } + + var iterator = function () { + if (!self._queue.length) { + return onFinish(null); + } var params = []; if(config.batching) { @@ -436,13 +439,15 @@ Visitor.prototype = { headers: self.options.headers || {} }); - request.post(path, options, fn); + request.post(path, options, nextIteration); } - async.whilst(test, iterator, function (err) { - self._log("Finished sending tracking calls") - fn.call(self, err || null, count - 1); - }); + function nextIteration(err) { + if (err) return onFinish(err); + iterator(); + } + + iterator(); }, diff --git a/package.json b/package.json index 161a2e7..24fd42e 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,6 @@ "tracking" ], "dependencies": { - "async": "1.2.x", "request": "2.x", "uuid": "^3.0.0" }, From b1d7dcd18d5f444aefd7c2273ff9ff12d7601e7c Mon Sep 17 00:00:00 2001 From: Aesop Wolf Date: Mon, 15 May 2017 12:36:57 -0700 Subject: [PATCH 03/13] Fix markdown formatting Markdown requires spaces after the 'atx' style headers (i.e. `### Title` vs `###Title`) --- AcceptableParams.md | 230 ++++++++++++++++++++++---------------------- 1 file changed, 115 insertions(+), 115 deletions(-) diff --git a/AcceptableParams.md b/AcceptableParams.md index 0d5a070..ce206a4 100644 --- a/AcceptableParams.md +++ b/AcceptableParams.md @@ -1,756 +1,756 @@ -#Acceptable parameters +# Acceptable parameters ------ -##Protocol Version +## Protocol Version Pass as: `protocolVersion` or `v` Required for all hit types.The Protocol version. The current value is '1'. This will only change when there are changes made that are not backwards compatible. -##Tracking ID / Web Property ID +## Tracking ID / Web Property ID Pass as: `trackingId` or `webPropertyId` or `tid` Required for all hit types.The tracking ID / web property ID. The format is UA-XXXX-Y. All collected data is associated by this ID. -##Anonymize IP +## Anonymize IP Pass as: `anonymizeIp` or `aip` Optional. When present, the IP address of the sender will be anonymized. For example, the IP will be anonymized if any of the following parameters are present in the payload: &aip=, &aip=0, or &aip=1 -##Data Source +## Data Source Pass as: `dataSource` or `ds` Optional. Indicates the data source of the hit. Hits sent from analytics.js will have data source set to 'web'; hits sent from one of the mobile SDKs will have data source set to 'app'. -##Queue Time +## Queue Time Pass as: `queueTime` or `qt` Optional. Used to collect offline / latent hits. The value represents the time delta (in milliseconds) between when the hit being reported occurred and the time the hit was sent. The value must be greater than or equal to 0. Values greater than four hours may lead to hits not being processed. -##Cache Buster +## Cache Buster Pass as: `cacheBuster` or `z` Optional. Used to send a random number in GET requests to ensure browsers and proxies don't cache hits. It should be sent as the final parameter of the request since we've seen some 3rd party internet filtering software add additional parameters to HTTP requests incorrectly. This value is not used in reporting. -##Client ID +## Client ID Pass as: `clientId` or `cid` Required for all hit types.This anonymously identifies a particular user, device, or browser instance. For the web, this is generally stored as a first-party cookie with a two-year expiration. For mobile apps, this is randomly generated for each particular instance of an application install. The value of this field should be a random UUID (version 4) as described in http://www.ietf.org/rfc/rfc4122.txt -##User ID +## User ID Pass as: `userId` or `uid` Optional. This is intended to be a known identifier for a user provided by the site owner/tracking library user. It may not itself be PII. The value should never be persisted in GA cookies or other Analytics provided storage. -##Session Control +## Session Control Pass as: `sessionControl` or `sc` Optional. Used to control the session duration. A value of 'start' forces a new session to start with this hit and 'end' forces the current session to end with this hit. All other values are ignored. -##IP Override +## IP Override Pass as: `ipOverride` or `uip` Optional. The IP address of the user. This should be a valid IP address. It will always be anonymized just as though &aip (anonymize IP) had been used. -##User Agent Override +## User Agent Override Pass as: `userAgentOverride` or `ua` Optional. The User Agent of the browser. Note that Google has libraries to identify real user agents. Hand crafting your own agent could break at any time. -##Geographical Override +## Geographical Override Pass as: `geoid` Optional. The geographical location of the user. The geographical ID should be a two letter country code or a criteria ID representing a city or region (see http://developers.google.com/analytics/devguides/collection/protocol/v1/geoid). This parameter takes precedent over any location derived from IP address, including the IP Override parameter. An invalid code will result in geographical dimensions to be set to '(not set)'. -##Document Referrer +## Document Referrer Pass as: `documentReferrer` or `dr` Optional. Specifies which referral source brought traffic to a website. This value is also used to compute the traffic source. The format of this value is a URL. -##Campaign Name +## Campaign Name Pass as: `campaignName` or `cn` Optional. Specifies the campaign name. -##Campaign Source +## Campaign Source Pass as: `campaignSource` or `cs` Optional. Specifies the campaign source. -##Campaign Medium +## Campaign Medium Pass as: `campaignMedium` or `cm` Optional. Specifies the campaign medium. -##Campaign Keyword +## Campaign Keyword Pass as: `campaignKeyword` or `ck` Optional. Specifies the campaign keyword. -##Campaign Content +## Campaign Content Pass as: `campaignContent` or `cc` Optional. Specifies the campaign content. -##Campaign ID +## Campaign ID Pass as: `campaignId` or `ci` Optional. Specifies the campaign ID. -##Google AdWords ID +## Google AdWords ID Pass as: `googleAdwordsId` or `gclid` Optional. Specifies the Google AdWords Id. -##Google Display Ads ID +## Google Display Ads ID Pass as: `googleDisplayAdsId` or `dclid` Optional. Specifies the Google Display Ads Id. -##Screen Resolution +## Screen Resolution Pass as: `screenResolution` or `sr` Optional. Specifies the screen resolution. -##Viewport size +## Viewport size Pass as: `viewportSize` or `vp` Optional. Specifies the viewable area of the browser / device. -##Document Encoding +## Document Encoding Pass as: `documentEncoding` or `de` Optional. Specifies the character set used to encode the page / document. -##Screen Colors +## Screen Colors Pass as: `screenColors` or `sd` Optional. Specifies the screen color depth. -##User Language +## User Language Pass as: `userLanguage` or `ul` Optional. Specifies the language. -##Java Enabled +## Java Enabled Pass as: `javaEnabled` or `je` Optional. Specifies whether Java was enabled. -##Flash Version +## Flash Version Pass as: `flashVersion` or `fl` Optional. Specifies the flash version. -##Hit type +## Hit type Pass as: `hitType` or `t` Required for all hit types.The type of hit. Must be one of 'pageview', 'screenview', 'event', 'transaction', 'item', 'social', 'exception', 'timing'. -##Non-Interaction Hit +## Non-Interaction Hit Pass as: `non-interactionHit` or `ni` Optional. Specifies that a hit be considered non-interactive. -##Document location URL +## Document location URL Pass as: `documentLocationUrl` or `dl` Optional. Use this parameter to send the full URL (document location) of the page on which content resides. You can use the &dh and &dp parameters to override the hostname and path + query portions of the document location, accordingly. The JavaScript clients determine this parameter using the concatenation of the document.location.origin + document.location.pathname + document.location.search browser parameters. Be sure to remove any user authentication or other private information from the URL if present. -##Document Host Name +## Document Host Name Pass as: `documentHostName` or `dh` Optional. Specifies the hostname from which content was hosted. -##Document Path +## Document Path Pass as: `documentPath` or `dp` Optional. The path portion of the page URL. Should begin with '/'. -##Document Title +## Document Title Pass as: `documentTitle` or `dt` Optional. The title of the page / document. -##Screen Name +## Screen Name Pass as: `screenName` or `cd` Optional. If not specified, this will default to the unique URL of the page by either using the &dl parameter as-is or assembling it from &dh and &dp. App tracking makes use of this for the 'Screen Name' of the screenview hit. -##Link ID +## Link ID Pass as: `linkId` or `linkid` Optional. The ID of a clicked DOM element, used to disambiguate multiple links to the same URL in In-Page Analytics reports when Enhanced Link Attribution is enabled for the property. -##Application Name +## Application Name Pass as: `applicationName` or `an` Optional. Specifies the application name. -##Application ID +## Application ID Pass as: `applicationId` or `aid` Optional. Application identifier. -##Application Version +## Application Version Pass as: `applicationVersion` or `av` Optional. Specifies the application version. -##Application Installer ID +## Application Installer ID Pass as: `applicationInstallerId` or `aiid` Optional. Application installer identifier. -##Event Category +## Event Category Pass as: `eventCategory` or `ec` Optional. Specifies the event category. Must not be empty. -##Event Action +## Event Action Pass as: `eventAction` or `ea` Optional.Specifies the event action.Must not be empty. -##Event Label +## Event Label Pass as: `eventLabel` or `el` Optional. Specifies the event label. -##Event Value +## Event Value Pass as: `eventValue` or `ev` Optional. Specifies the event value. Values must be non-negative. -##Transaction ID +## Transaction ID Pass as: `transactionId` or `ti` Required for transaction hit type.Required for item hit type.A unique identifier for the transaction. This value should be the same for both the Transaction hit and Items hits associated to the particular transaction. -##Transaction Affiliation +## Transaction Affiliation Pass as: `transactionAffiliation` or `ta` Optional. Specifies the affiliation or store name. -##Transaction Revenue +## Transaction Revenue Pass as: `transactionRevenue` or `tr` Optional. Specifies the total revenue associated with the transaction. This value should include any shipping or tax costs. -##Transaction Shipping +## Transaction Shipping Pass as: `transactionShipping` or `ts` Optional. Specifies the total shipping cost of the transaction. -##Transaction Tax +## Transaction Tax Pass as: `transactionTax` or `tt` Optional. Specifies the total tax of the transaction. -##Item Name +## Item Name Pass as: `itemName` or `in` Required for item hit type.Specifies the item name. -##Item Price +## Item Price Pass as: `itemPrice` or `ip` Optional. Specifies the price for a single item / unit. -##Item Quantity +## Item Quantity Pass as: `itemQuantity` or `iq` Optional. Specifies the number of items purchased. -##Item Code +## Item Code Pass as: `itemCode` or `ic` Optional. Specifies the SKU or item code. -##Item Category +## Item Category Pass as: `itemCategory` or `iv` Optional. Specifies the category that the item belongs to. -##Currency Code +## Currency Code Pass as: `currencyCode` or `cu` Optional. When present indicates the local currency for all transaction currency values. Value should be a valid ISO 4217 currency code. -##Social Network +## Social Network Pass as: `socialNetwork` or `sn` Required for social hit type.Specifies the social network, for example Facebook or Google Plus. -##Social Action +## Social Action Pass as: `socialAction` or `sa` Required for social hit type.Specifies the social interaction action. For example on Google Plus when a user clicks the +1 button, the social action is 'plus'. -##Social Action Target +## Social Action Target Pass as: `socialActionTarget` or `st` Required for social hit type.Specifies the target of a social interaction. This value is typically a URL but can be any text. -##User timing category +## User timing category Pass as: `userTimingCategory` or `utc` Optional. Specifies the user timing category. -##User timing variable name +## User timing variable name Pass as: `userTimingVariableName` or `utv` Optional. Specifies the user timing variable. -##User timing time +## User timing time Pass as: `userTimingTime` or `utt` Optional. Specifies the user timing value. The value is in milliseconds. -##User timing label +## User timing label Pass as: `userTimingLabel` or `utl` Optional. Specifies the user timing label. -##Page Load Time +## Page Load Time Pass as: `pageLoadTime` or `plt` Optional. Specifies the time it took for a page to load. The value is in milliseconds. -##DNS Time +## DNS Time Pass as: `dnsTime` or `dns` Optional. Specifies the time it took to do a DNS lookup.The value is in milliseconds. -##Page Download Time +## Page Download Time Pass as: `pageDownloadTime` or `pdt` Optional. Specifies the time it took for the page to be downloaded. The value is in milliseconds. -##Redirect Response Time +## Redirect Response Time Pass as: `redirectResponseTime` or `rrt` Optional. Specifies the time it took for any redirects to happen. The value is in milliseconds. -##TCP Connect Time +## TCP Connect Time Pass as: `tcpConnectTime` or `tcp` Optional. Specifies the time it took for a TCP connection to be made. The value is in milliseconds. -##Server Response Time +## Server Response Time Pass as: `serverResponseTime` or `srt` Optional. Specifies the time it took for the server to respond after the connect time. The value is in milliseconds. -##DOM Interactive Time +## DOM Interactive Time Pass as: `domInteractiveTime` or `dit` Optional. Specifies the time it took for Document.readyState to be 'interactive'. The value is in milliseconds. -##Content Load Time +## Content Load Time Pass as: `contentLoadTime` or `clt` Optional. Specifies the time it took for the DOMContentLoaded Event to fire. The value is in milliseconds. -##Exception Description +## Exception Description Pass as: `exceptionDescription` or `exd` Optional. Specifies the description of an exception. -##Is Exception Fatal? +## Is Exception Fatal? Pass as: `isExceptionFatal` or `exf` Optional. Specifies whether the exception was fatal. -##Custom Dimension +## Custom Dimension Pass as: `cd[1-9][0-9]*` Optional. Each custom dimension has an associated index. There is a maximum of 20 custom dimensions (200 for Premium accounts). The name suffix must be a positive integer between 1 and 200, inclusive. -##Custom Metric +## Custom Metric Pass as: `cm[1-9][0-9]*` Optional. Each custom metric has an associated index. There is a maximum of 20 custom metrics (200 for Premium accounts). The name suffix must be a positive integer between 1 and 200, inclusive. -##Content Group +## Content Group Pass as: `cg(10|[0-9])` Optional. Up to 10 content groups are possible. -##Experiment ID +## Experiment ID Pass as: `experimentId` or `xid` Optional. This parameter specifies that this user has been exposed to an experiment with the given ID. It should be sent in conjunction with the Experiment Variant parameter. -##Experiment Variant +## Experiment Variant Pass as: `experimentVariant` or `xvar` Optional. This parameter specifies that this user has been exposed to a particular variation of an experiment. It should be sent in conjunction with the Experiment ID parameter. -##Enhanced e-commerce +## Enhanced e-commerce To use enhanced e-commerce you must explicitly enable it in Google Analytics admin. Some parameters overlap with regular e-commerce tracking (`ti`, `ta`, `tr`, `tt`, `ts`), however item tracking is different. You may generate enhanced e-commerce using the [`gampee`](https://www.npmjs.com/package/gampee) module. -###Product SKU +### Product SKU Pass as: `pr[0-9]{1,3}id` Optional. The SKU of the product. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Name +### Product Name Pass as: `pr[0-9]{1,3}nm` Optional. The name of the product. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Brand +### Product Brand Pass as: `pr[0-9]{1,3}br` Optional. The brand associated with the product. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Category +### Product Category Pass as: `pr[0-9]{1,3}ca` Optional. The category to which the product belongs. Product index must be a positive integer between 1 and 200, inclusive. The product category parameter can be hierarchical. Use / as a delimiter to specify up to 5-levels of hierarchy. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Variant +### Product Variant Pass as: `pr[0-9]{1,3}va` Optional. The variant of the product. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Price +### Product Price Pass as: `pr[0-9]{1,3}pr` Optional. The price of a product. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Quantity +### Product Quantity Pass as: `pr[0-9]{1,3}qt` Optional. The quantity of a product. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Coupon Code +### Product Coupon Code Pass as: `pr[0-9]{1,3}cc` Optional. The coupon code associated with a product. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Position +### Product Position Pass as: `pr[0-9]{1,3}ps` Optional. The product's position in a list or collection. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Custom Dimension +### Product Custom Dimension Pass as: `pr[0-9]{1,3}cd[0-9]{1,3}` Optional. A product-level custom dimension where dimension index is a positive integer between 1 and 200, inclusive. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Custom Metric +### Product Custom Metric Pass as: `pr[0-9]{1,3}cm[0-9]{1,3}` Optional. A product-level custom metric where metric index is a positive integer between 1 and 200, inclusive. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Action +### Product Action Pass as: `pa` Optional. The role of the products included in a hit. If a product action is not specified, all product definitions included with the hit will be ignored. Must be one of: detail, click, add, remove, checkout, checkout_option, purchase, refund. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Transaction ID +### Transaction ID Pass as: `ti` Optional. The transaction ID. This is an additional parameter that can be sent when Product Action is set to 'purchase' or 'refund'. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Affiliation +### Affiliation Pass as: `ta` Optional. The store or affiliation from which this transaction occurred. This is an additional parameter that can be sent when Product Action is set to 'purchase' or 'refund'. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Revenue +### Revenue Pass as: `tr` Optional. The total value of the transaction, including tax and shipping. If not sent, this value will be automatically calculated using the product quantity and price fields of all products in the same hit. This is an additional parameter that can be sent when Product Action is set to 'purchase' or 'refund'. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Tax +### Tax Pass as: `tt` Optional. The total tax associated with the transaction. This is an additional parameter that can be sent when Product Action is set to 'purchase' or 'refund'. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Shipping +### Shipping Pass as: `ts` Optional. The shipping cost associated with the transaction. This is an additional parameter that can be sent when Product Action is set to 'purchase' or 'refund'. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Coupon Code +### Coupon Code Pass as: `tcc` Optional. The transaction coupon redeemed with the transaction. This is an additional parameter that can be sent when Product Action is set to 'purchase' or 'refund'. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Action List +### Product Action List Pass as: `pal` Optional. The list or collection from which a product action occurred. This is an additional parameter that can be sent when Product Action is set to 'detail' or 'click'. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Checkout Step +### Checkout Step Pass as: `cos` Optional. The step number in a checkout funnel. This is an additional parameter that can be sent when Product Action is set to 'checkout'. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Checkout Step Option +### Checkout Step Option Pass as: `col` Optional. Additional information about a checkout step. This is an additional parameter that can be sent when Product Action is set to 'checkout'. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Impression List Name +### Product Impression List Name Pass as: `il[0-9]{1,3}nm` Optional. The list or collection to which a product belongs. Impression List index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Impression SKU +### Product Impression SKU Pass as: `il[0-9]{1,3}pi[0-9]{1,3}id` Optional. The product ID or SKU. Impression List index must be a positive integer between 1 and 200, inclusive. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Impression Name +### Product Impression Name Pass as: `il[0-9]{1,3}pi[0-9]{1,3}nm` Optional. The name of the product. Impression List index must be a positive integer between 1 and 200, inclusive. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Impression Brand +### Product Impression Brand Pass as: `il[0-9]{1,3}pi[0-9]{1,3}br` Optional. The brand associated with the product. Impression List index must be a positive integer between 1 and 200, inclusive. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Impression Category +### Product Impression Category Pass as: `il[0-9]{1,3}pi[0-9]{1,3}ca` Optional. The category to which the product belongs. Impression List index must be a positive integer between 1 and 200, inclusive. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Impression Variant +### Product Impression Variant Pass as: `il[0-9]{1,3}pi[0-9]{1,3}va` Optional. The variant of the product. Impression List index must be a positive integer between 1 and 200, inclusive. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Impression Position +### Product Impression Position Pass as: `il[0-9]{1,3}pi[0-9]{1,3}ps` Optional. The product's position in a list or collection. Impression List index must be a positive integer between 1 and 200, inclusive. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Impression Price +### Product Impression Price Pass as: `il[0-9]{1,3}pi[0-9]{1,3}pr` Optional. The price of a product. Impression List index must be a positive integer between 1 and 200, inclusive. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Impression Custom Dimension +### Product Impression Custom Dimension Pass as: `il[0-9]{1,3}pi[0-9]{1,3}cd[0-9]{1,3}` Optional. A product-level custom dimension where dimension index is a positive integer between 1 and 200, inclusive. Impression List index must be a positive integer between 1 and 200, inclusive. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Impression Custom Metric +### Product Impression Custom Metric Pass as: `il[0-9]{1,3}pi[0-9]{1,3}cm[0-9]{1,3}` Optional. A product-level custom metric where metric index is a positive integer between 1 and 200, inclusive. Impression List index must be a positive integer between 1 and 200, inclusive. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Promotion ID +### Promotion ID Pass as: `promo[0-9]{1,3}id` Optional. The promotion ID. Promotion index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Promotion Name +### Promotion Name Pass as: `promo[0-9]{1,3}nm` Optional. The name of the promotion. Promotion index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Promotion Creative +### Promotion Creative Pass as: `promo[0-9]{1,3}cr` Optional. The creative associated with the promotion. Promotion index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Promotion Position +### Promotion Position Pass as: `promo[0-9]{1,3}ps` Optional. The position of the creative. Promotion index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Promotion Action +### Promotion Action Pass as: `promoa` From 940c55f9dc2de50660b7ea0dfdf31ec99b1456a9 Mon Sep 17 00:00:00 2001 From: Gus Caplan Date: Sat, 5 Aug 2017 17:48:43 -0500 Subject: [PATCH 04/13] Update AcceptableParams.md --- AcceptableParams.md | 230 ++++++++++++++++++++++---------------------- 1 file changed, 115 insertions(+), 115 deletions(-) diff --git a/AcceptableParams.md b/AcceptableParams.md index 0d5a070..16ebc58 100644 --- a/AcceptableParams.md +++ b/AcceptableParams.md @@ -1,186 +1,186 @@ -#Acceptable parameters +# Acceptable parameters ------ -##Protocol Version +## Protocol Version Pass as: `protocolVersion` or `v` Required for all hit types.The Protocol version. The current value is '1'. This will only change when there are changes made that are not backwards compatible. -##Tracking ID / Web Property ID +## Tracking ID / Web Property ID Pass as: `trackingId` or `webPropertyId` or `tid` Required for all hit types.The tracking ID / web property ID. The format is UA-XXXX-Y. All collected data is associated by this ID. -##Anonymize IP +## Anonymize IP Pass as: `anonymizeIp` or `aip` Optional. When present, the IP address of the sender will be anonymized. For example, the IP will be anonymized if any of the following parameters are present in the payload: &aip=, &aip=0, or &aip=1 -##Data Source +## Data Source Pass as: `dataSource` or `ds` Optional. Indicates the data source of the hit. Hits sent from analytics.js will have data source set to 'web'; hits sent from one of the mobile SDKs will have data source set to 'app'. -##Queue Time +## Queue Time Pass as: `queueTime` or `qt` Optional. Used to collect offline / latent hits. The value represents the time delta (in milliseconds) between when the hit being reported occurred and the time the hit was sent. The value must be greater than or equal to 0. Values greater than four hours may lead to hits not being processed. -##Cache Buster +## Cache Buster Pass as: `cacheBuster` or `z` Optional. Used to send a random number in GET requests to ensure browsers and proxies don't cache hits. It should be sent as the final parameter of the request since we've seen some 3rd party internet filtering software add additional parameters to HTTP requests incorrectly. This value is not used in reporting. -##Client ID +## Client ID Pass as: `clientId` or `cid` Required for all hit types.This anonymously identifies a particular user, device, or browser instance. For the web, this is generally stored as a first-party cookie with a two-year expiration. For mobile apps, this is randomly generated for each particular instance of an application install. The value of this field should be a random UUID (version 4) as described in http://www.ietf.org/rfc/rfc4122.txt -##User ID +## User ID Pass as: `userId` or `uid` Optional. This is intended to be a known identifier for a user provided by the site owner/tracking library user. It may not itself be PII. The value should never be persisted in GA cookies or other Analytics provided storage. -##Session Control +## Session Control Pass as: `sessionControl` or `sc` Optional. Used to control the session duration. A value of 'start' forces a new session to start with this hit and 'end' forces the current session to end with this hit. All other values are ignored. -##IP Override +## IP Override Pass as: `ipOverride` or `uip` Optional. The IP address of the user. This should be a valid IP address. It will always be anonymized just as though &aip (anonymize IP) had been used. -##User Agent Override +## User Agent Override Pass as: `userAgentOverride` or `ua` Optional. The User Agent of the browser. Note that Google has libraries to identify real user agents. Hand crafting your own agent could break at any time. -##Geographical Override +## Geographical Override Pass as: `geoid` Optional. The geographical location of the user. The geographical ID should be a two letter country code or a criteria ID representing a city or region (see http://developers.google.com/analytics/devguides/collection/protocol/v1/geoid). This parameter takes precedent over any location derived from IP address, including the IP Override parameter. An invalid code will result in geographical dimensions to be set to '(not set)'. -##Document Referrer +## Document Referrer Pass as: `documentReferrer` or `dr` Optional. Specifies which referral source brought traffic to a website. This value is also used to compute the traffic source. The format of this value is a URL. -##Campaign Name +## Campaign Name Pass as: `campaignName` or `cn` Optional. Specifies the campaign name. -##Campaign Source +## Campaign Source Pass as: `campaignSource` or `cs` Optional. Specifies the campaign source. -##Campaign Medium +## Campaign Medium Pass as: `campaignMedium` or `cm` Optional. Specifies the campaign medium. -##Campaign Keyword +## Campaign Keyword Pass as: `campaignKeyword` or `ck` Optional. Specifies the campaign keyword. -##Campaign Content +## Campaign Content Pass as: `campaignContent` or `cc` Optional. Specifies the campaign content. -##Campaign ID +## Campaign ID Pass as: `campaignId` or `ci` Optional. Specifies the campaign ID. -##Google AdWords ID +## Google AdWords ID Pass as: `googleAdwordsId` or `gclid` Optional. Specifies the Google AdWords Id. -##Google Display Ads ID +## Google Display Ads ID Pass as: `googleDisplayAdsId` or `dclid` Optional. Specifies the Google Display Ads Id. -##Screen Resolution +## Screen Resolution Pass as: `screenResolution` or `sr` Optional. Specifies the screen resolution. -##Viewport size +## Viewport size Pass as: `viewportSize` or `vp` Optional. Specifies the viewable area of the browser / device. -##Document Encoding +## Document Encoding Pass as: `documentEncoding` or `de` Optional. Specifies the character set used to encode the page / document. -##Screen Colors +## Screen Colors Pass as: `screenColors` or `sd` Optional. Specifies the screen color depth. -##User Language +## User Language Pass as: `userLanguage` or `ul` Optional. Specifies the language. -##Java Enabled +## Java Enabled Pass as: `javaEnabled` or `je` @@ -194,126 +194,126 @@ Pass as: `flashVersion` or `fl` Optional. Specifies the flash version. -##Hit type +## Hit type Pass as: `hitType` or `t` Required for all hit types.The type of hit. Must be one of 'pageview', 'screenview', 'event', 'transaction', 'item', 'social', 'exception', 'timing'. -##Non-Interaction Hit +## Non-Interaction Hit Pass as: `non-interactionHit` or `ni` Optional. Specifies that a hit be considered non-interactive. -##Document location URL +## Document location URL Pass as: `documentLocationUrl` or `dl` Optional. Use this parameter to send the full URL (document location) of the page on which content resides. You can use the &dh and &dp parameters to override the hostname and path + query portions of the document location, accordingly. The JavaScript clients determine this parameter using the concatenation of the document.location.origin + document.location.pathname + document.location.search browser parameters. Be sure to remove any user authentication or other private information from the URL if present. -##Document Host Name +## Document Host Name Pass as: `documentHostName` or `dh` Optional. Specifies the hostname from which content was hosted. -##Document Path +## Document Path Pass as: `documentPath` or `dp` Optional. The path portion of the page URL. Should begin with '/'. -##Document Title +## Document Title Pass as: `documentTitle` or `dt` Optional. The title of the page / document. -##Screen Name +## Screen Name Pass as: `screenName` or `cd` Optional. If not specified, this will default to the unique URL of the page by either using the &dl parameter as-is or assembling it from &dh and &dp. App tracking makes use of this for the 'Screen Name' of the screenview hit. -##Link ID +## Link ID Pass as: `linkId` or `linkid` Optional. The ID of a clicked DOM element, used to disambiguate multiple links to the same URL in In-Page Analytics reports when Enhanced Link Attribution is enabled for the property. -##Application Name +## Application Name Pass as: `applicationName` or `an` Optional. Specifies the application name. -##Application ID +## Application ID Pass as: `applicationId` or `aid` Optional. Application identifier. -##Application Version +## Application Version Pass as: `applicationVersion` or `av` Optional. Specifies the application version. -##Application Installer ID +## Application Installer ID Pass as: `applicationInstallerId` or `aiid` Optional. Application installer identifier. -##Event Category +## Event Category Pass as: `eventCategory` or `ec` Optional. Specifies the event category. Must not be empty. -##Event Action +##E vent Action Pass as: `eventAction` or `ea` -Optional.Specifies the event action.Must not be empty. +Optional.Specifies the event action. Must not be empty. -##Event Label +## Event Label Pass as: `eventLabel` or `el` Optional. Specifies the event label. -##Event Value +## Event Value Pass as: `eventValue` or `ev` Optional. Specifies the event value. Values must be non-negative. -##Transaction ID +## Transaction ID Pass as: `transactionId` or `ti` Required for transaction hit type.Required for item hit type.A unique identifier for the transaction. This value should be the same for both the Transaction hit and Items hits associated to the particular transaction. -##Transaction Affiliation +## Transaction Affiliation Pass as: `transactionAffiliation` or `ta` @@ -327,430 +327,430 @@ Pass as: `transactionRevenue` or `tr` Optional. Specifies the total revenue associated with the transaction. This value should include any shipping or tax costs. -##Transaction Shipping +## Transaction Shipping Pass as: `transactionShipping` or `ts` Optional. Specifies the total shipping cost of the transaction. -##Transaction Tax +## Transaction Tax Pass as: `transactionTax` or `tt` Optional. Specifies the total tax of the transaction. -##Item Name +## Item Name Pass as: `itemName` or `in` Required for item hit type.Specifies the item name. -##Item Price +## Item Price Pass as: `itemPrice` or `ip` Optional. Specifies the price for a single item / unit. -##Item Quantity +## Item Quantity Pass as: `itemQuantity` or `iq` Optional. Specifies the number of items purchased. -##Item Code +## Item Code Pass as: `itemCode` or `ic` Optional. Specifies the SKU or item code. -##Item Category +## Item Category Pass as: `itemCategory` or `iv` Optional. Specifies the category that the item belongs to. -##Currency Code +## Currency Code Pass as: `currencyCode` or `cu` Optional. When present indicates the local currency for all transaction currency values. Value should be a valid ISO 4217 currency code. -##Social Network +## Social Network Pass as: `socialNetwork` or `sn` Required for social hit type.Specifies the social network, for example Facebook or Google Plus. -##Social Action +## Social Action Pass as: `socialAction` or `sa` Required for social hit type.Specifies the social interaction action. For example on Google Plus when a user clicks the +1 button, the social action is 'plus'. -##Social Action Target +## Social Action Target Pass as: `socialActionTarget` or `st` Required for social hit type.Specifies the target of a social interaction. This value is typically a URL but can be any text. -##User timing category +## User timing category Pass as: `userTimingCategory` or `utc` Optional. Specifies the user timing category. -##User timing variable name +## User timing variable name Pass as: `userTimingVariableName` or `utv` Optional. Specifies the user timing variable. -##User timing time +## User timing time Pass as: `userTimingTime` or `utt` Optional. Specifies the user timing value. The value is in milliseconds. -##User timing label +## User timing label Pass as: `userTimingLabel` or `utl` Optional. Specifies the user timing label. -##Page Load Time +## Page Load Time Pass as: `pageLoadTime` or `plt` Optional. Specifies the time it took for a page to load. The value is in milliseconds. -##DNS Time +## DNS Time Pass as: `dnsTime` or `dns` -Optional. Specifies the time it took to do a DNS lookup.The value is in milliseconds. +Optional. Specifies the time it took to do a DNS lookup. The value is in milliseconds. -##Page Download Time +## Page Download Time Pass as: `pageDownloadTime` or `pdt` Optional. Specifies the time it took for the page to be downloaded. The value is in milliseconds. -##Redirect Response Time +## Redirect Response Time Pass as: `redirectResponseTime` or `rrt` Optional. Specifies the time it took for any redirects to happen. The value is in milliseconds. -##TCP Connect Time +## TCP Connect Time Pass as: `tcpConnectTime` or `tcp` Optional. Specifies the time it took for a TCP connection to be made. The value is in milliseconds. -##Server Response Time +## Server Response Time Pass as: `serverResponseTime` or `srt` Optional. Specifies the time it took for the server to respond after the connect time. The value is in milliseconds. -##DOM Interactive Time +## DOM Interactive Time Pass as: `domInteractiveTime` or `dit` Optional. Specifies the time it took for Document.readyState to be 'interactive'. The value is in milliseconds. -##Content Load Time +## Content Load Time Pass as: `contentLoadTime` or `clt` Optional. Specifies the time it took for the DOMContentLoaded Event to fire. The value is in milliseconds. -##Exception Description +## Exception Description Pass as: `exceptionDescription` or `exd` Optional. Specifies the description of an exception. -##Is Exception Fatal? +## Is Exception Fatal? Pass as: `isExceptionFatal` or `exf` Optional. Specifies whether the exception was fatal. -##Custom Dimension +## Custom Dimension Pass as: `cd[1-9][0-9]*` Optional. Each custom dimension has an associated index. There is a maximum of 20 custom dimensions (200 for Premium accounts). The name suffix must be a positive integer between 1 and 200, inclusive. -##Custom Metric +## Custom Metric Pass as: `cm[1-9][0-9]*` Optional. Each custom metric has an associated index. There is a maximum of 20 custom metrics (200 for Premium accounts). The name suffix must be a positive integer between 1 and 200, inclusive. -##Content Group +## Content Group Pass as: `cg(10|[0-9])` Optional. Up to 10 content groups are possible. -##Experiment ID +## Experiment ID Pass as: `experimentId` or `xid` Optional. This parameter specifies that this user has been exposed to an experiment with the given ID. It should be sent in conjunction with the Experiment Variant parameter. -##Experiment Variant +## Experiment Variant Pass as: `experimentVariant` or `xvar` Optional. This parameter specifies that this user has been exposed to a particular variation of an experiment. It should be sent in conjunction with the Experiment ID parameter. -##Enhanced e-commerce +## Enhanced e-commerce To use enhanced e-commerce you must explicitly enable it in Google Analytics admin. Some parameters overlap with regular e-commerce tracking (`ti`, `ta`, `tr`, `tt`, `ts`), however item tracking is different. You may generate enhanced e-commerce using the [`gampee`](https://www.npmjs.com/package/gampee) module. -###Product SKU +### Product SKU Pass as: `pr[0-9]{1,3}id` Optional. The SKU of the product. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Name +### Product Name Pass as: `pr[0-9]{1,3}nm` Optional. The name of the product. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Brand +### Product Brand Pass as: `pr[0-9]{1,3}br` Optional. The brand associated with the product. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Category +### Product Category Pass as: `pr[0-9]{1,3}ca` Optional. The category to which the product belongs. Product index must be a positive integer between 1 and 200, inclusive. The product category parameter can be hierarchical. Use / as a delimiter to specify up to 5-levels of hierarchy. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Variant +### Product Variant Pass as: `pr[0-9]{1,3}va` Optional. The variant of the product. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Price +### Product Price Pass as: `pr[0-9]{1,3}pr` Optional. The price of a product. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Quantity +### Product Quantity Pass as: `pr[0-9]{1,3}qt` Optional. The quantity of a product. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Coupon Code +### Product Coupon Code Pass as: `pr[0-9]{1,3}cc` Optional. The coupon code associated with a product. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Position +### Product Position Pass as: `pr[0-9]{1,3}ps` Optional. The product's position in a list or collection. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Custom Dimension +### Product Custom Dimension Pass as: `pr[0-9]{1,3}cd[0-9]{1,3}` Optional. A product-level custom dimension where dimension index is a positive integer between 1 and 200, inclusive. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Custom Metric +### Product Custom Metric Pass as: `pr[0-9]{1,3}cm[0-9]{1,3}` Optional. A product-level custom metric where metric index is a positive integer between 1 and 200, inclusive. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Action +### Product Action Pass as: `pa` Optional. The role of the products included in a hit. If a product action is not specified, all product definitions included with the hit will be ignored. Must be one of: detail, click, add, remove, checkout, checkout_option, purchase, refund. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Transaction ID +### Transaction ID Pass as: `ti` Optional. The transaction ID. This is an additional parameter that can be sent when Product Action is set to 'purchase' or 'refund'. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Affiliation +### Affiliation Pass as: `ta` Optional. The store or affiliation from which this transaction occurred. This is an additional parameter that can be sent when Product Action is set to 'purchase' or 'refund'. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Revenue +### Revenue Pass as: `tr` Optional. The total value of the transaction, including tax and shipping. If not sent, this value will be automatically calculated using the product quantity and price fields of all products in the same hit. This is an additional parameter that can be sent when Product Action is set to 'purchase' or 'refund'. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Tax +### Tax Pass as: `tt` Optional. The total tax associated with the transaction. This is an additional parameter that can be sent when Product Action is set to 'purchase' or 'refund'. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Shipping +### Shipping Pass as: `ts` Optional. The shipping cost associated with the transaction. This is an additional parameter that can be sent when Product Action is set to 'purchase' or 'refund'. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Coupon Code +### Coupon Code Pass as: `tcc` Optional. The transaction coupon redeemed with the transaction. This is an additional parameter that can be sent when Product Action is set to 'purchase' or 'refund'. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Action List +### Product Action List Pass as: `pal` Optional. The list or collection from which a product action occurred. This is an additional parameter that can be sent when Product Action is set to 'detail' or 'click'. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Checkout Step +### Checkout Step Pass as: `cos` Optional. The step number in a checkout funnel. This is an additional parameter that can be sent when Product Action is set to 'checkout'. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Checkout Step Option +### Checkout Step Option Pass as: `col` Optional. Additional information about a checkout step. This is an additional parameter that can be sent when Product Action is set to 'checkout'. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Impression List Name +### Product Impression List Name Pass as: `il[0-9]{1,3}nm` Optional. The list or collection to which a product belongs. Impression List index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Impression SKU +### Product Impression SKU Pass as: `il[0-9]{1,3}pi[0-9]{1,3}id` Optional. The product ID or SKU. Impression List index must be a positive integer between 1 and 200, inclusive. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Impression Name +### Product Impression Name Pass as: `il[0-9]{1,3}pi[0-9]{1,3}nm` Optional. The name of the product. Impression List index must be a positive integer between 1 and 200, inclusive. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Impression Brand +### Product Impression Brand Pass as: `il[0-9]{1,3}pi[0-9]{1,3}br` Optional. The brand associated with the product. Impression List index must be a positive integer between 1 and 200, inclusive. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Impression Category +### Product Impression Category Pass as: `il[0-9]{1,3}pi[0-9]{1,3}ca` Optional. The category to which the product belongs. Impression List index must be a positive integer between 1 and 200, inclusive. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Impression Variant +### Product Impression Variant Pass as: `il[0-9]{1,3}pi[0-9]{1,3}va` Optional. The variant of the product. Impression List index must be a positive integer between 1 and 200, inclusive. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Impression Position +### Product Impression Position Pass as: `il[0-9]{1,3}pi[0-9]{1,3}ps` Optional. The product's position in a list or collection. Impression List index must be a positive integer between 1 and 200, inclusive. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Impression Price +### Product Impression Price Pass as: `il[0-9]{1,3}pi[0-9]{1,3}pr` Optional. The price of a product. Impression List index must be a positive integer between 1 and 200, inclusive. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Impression Custom Dimension +### Product Impression Custom Dimension Pass as: `il[0-9]{1,3}pi[0-9]{1,3}cd[0-9]{1,3}` Optional. A product-level custom dimension where dimension index is a positive integer between 1 and 200, inclusive. Impression List index must be a positive integer between 1 and 200, inclusive. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Product Impression Custom Metric +### Product Impression Custom Metric Pass as: `il[0-9]{1,3}pi[0-9]{1,3}cm[0-9]{1,3}` Optional. A product-level custom metric where metric index is a positive integer between 1 and 200, inclusive. Impression List index must be a positive integer between 1 and 200, inclusive. Product index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Promotion ID +### Promotion ID Pass as: `promo[0-9]{1,3}id` Optional. The promotion ID. Promotion index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Promotion Name +### Promotion Name Pass as: `promo[0-9]{1,3}nm` Optional. The name of the promotion. Promotion index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Promotion Creative +### Promotion Creative Pass as: `promo[0-9]{1,3}cr` Optional. The creative associated with the promotion. Promotion index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Promotion Position +### Promotion Position Pass as: `promo[0-9]{1,3}ps` Optional. The position of the creative. Promotion index must be a positive integer between 1 and 200, inclusive. For analytics.js the Enhanced Ecommerce plugin must be installed before using this field. -###Promotion Action +### Promotion Action Pass as: `promoa` From 548d2a1f66b090f39636453aa1f064b8f9f5bb03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Tillmann?= Date: Mon, 7 Aug 2017 14:57:26 +0200 Subject: [PATCH 05/13] Updated Travis config and package.json --- .travis.yml | 7 ++++--- package.json | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 972240c..47b6854 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,10 @@ language: node_js node_js: - - "0.8" - - "0.10" - "0.12" - - "io.js" + - "4" + - "6" + - "8" + - "lts" before_install: - npm install -g npm diff --git a/package.json b/package.json index 8b814a6..7b3c908 100644 --- a/package.json +++ b/package.json @@ -19,12 +19,13 @@ "dependencies": { "async": "1.2.x", "request": "2.x", + "sinon": "^1.17.7", "underscore": "1.x", "uuid": "^3.0.0" }, "devDependencies": { "should": "*", - "sinon": "*", + "sinon": "^2", "mocha": "*" }, "author": "Jörg Tillmann ", From 627c1d28a1eddb6d0ffd9fd1ae148887804b703f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Tillmann?= Date: Mon, 7 Aug 2017 14:58:44 +0200 Subject: [PATCH 06/13] Version 0.4.14 --- HISTORY.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 37912b2..f873186 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,11 @@ # History +## 0.4.14 / 2017-08-07 + +- Updated AcceptableParams.md +- Updated .travis.yml to test Node.js up to 8 +- Updated package.json to be more specific about Sinon + ## 0.4.13 / 2017-03-29 - Added `screenview` method diff --git a/package.json b/package.json index 7b3c908..dd483e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "universal-analytics", - "version": "0.4.13", + "version": "0.4.14", "description": "A node module for Google's Universal Analytics tracking", "main": "index.js", "scripts": { From aec979a97b27dd98089c2bfd47626d4b4fd3464a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Tillmann?= Date: Thu, 10 Aug 2017 08:05:06 +0200 Subject: [PATCH 07/13] Fixed dependencies --- HISTORY.md | 4 ++++ package.json | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index f873186..d980d2f 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,9 @@ # History +## 0.4.15 / 2017-08-10 + +- Fixed dependencies + ## 0.4.14 / 2017-08-07 - Updated AcceptableParams.md diff --git a/package.json b/package.json index dd483e1..be23c70 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "universal-analytics", - "version": "0.4.14", + "version": "0.4.15", "description": "A node module for Google's Universal Analytics tracking", "main": "index.js", "scripts": { @@ -19,13 +19,12 @@ "dependencies": { "async": "1.2.x", "request": "2.x", - "sinon": "^1.17.7", "underscore": "1.x", "uuid": "^3.0.0" }, "devDependencies": { "should": "*", - "sinon": "^2", + "sinon": "^1.17.7", "mocha": "*" }, "author": "Jörg Tillmann ", From dc277b2c62a633972bc7123360270dd1aa0a5135 Mon Sep 17 00:00:00 2001 From: Canna Wen Date: Thu, 17 Aug 2017 12:53:15 +0200 Subject: [PATCH 08/13] Fix spacing for event action description in docs --- AcceptableParams.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AcceptableParams.md b/AcceptableParams.md index 16ebc58..6485005 100644 --- a/AcceptableParams.md +++ b/AcceptableParams.md @@ -285,11 +285,11 @@ Pass as: `eventCategory` or `ec` Optional. Specifies the event category. Must not be empty. -##E vent Action +## Event Action Pass as: `eventAction` or `ea` -Optional.Specifies the event action. Must not be empty. +Optional. Specifies the event action. Must not be empty. ## Event Label From 1ea9d7507d86cdf1b07b2e1ae7c9e72d50d8d1b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Tillmann?= Date: Fri, 24 Nov 2017 13:29:39 +0100 Subject: [PATCH 09/13] Updated travis config --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 47b6854..0b0d5bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,8 @@ language: node_js node_js: - - "0.12" - "4" - "6" - "8" - - "lts" before_install: - npm install -g npm From 93d9a25c26e349cd01a93b98d83ab84747013c58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Tillmann?= Date: Fri, 24 Nov 2017 13:32:07 +0100 Subject: [PATCH 10/13] Version 0.4.16 --- HISTORY.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index d980d2f..f292573 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,9 @@ # History +## 0.4.16 + +- Removed async, underscore dependencies + ## 0.4.15 / 2017-08-10 - Fixed dependencies diff --git a/package.json b/package.json index 344ef18..f77c7d5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "universal-analytics", - "version": "0.4.15", + "version": "0.4.16", "description": "A node module for Google's Universal Analytics tracking", "main": "index.js", "scripts": { From f01864c535956bdc4b5b1b3eb2b4e5ffa98f8c4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Tillmann?= Date: Tue, 19 Dec 2017 12:15:01 +0100 Subject: [PATCH 11/13] Updated Docs to be more clear regarding client and user ID --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8611b6f..8fdd7c3 100644 --- a/README.md +++ b/README.md @@ -46,16 +46,16 @@ Initialization expects at least your Google Analytics account ID: var visitor = ua('UA-XXXX-XX'); ``` -This will create a `universal-analytics` Visitor instance that you can use and keep around to track a specific user. Since no user UUID was specified in the constructor's arguments, a random UUID is generated. In case you have a user UUID at hand, you can use that to create the visitor: +This will create a `universal-analytics` Visitor instance that you can use and keep around to track a specific client (Not to be confused with the Google Analytics User ID, see [Setting persistent parameters](#setting-persistent-parameters) for more information on that). Since no client ID was specified in the constructor's arguments, a random UUID is generated. In case you have a client ID at hand, you can use that to create the visitor: ```javascript var visitor = ua('UA-XXXX-XX', '6a14abda-6b12-4578-bf66-43c754eaeda9'); ``` -Starting with Universal Analytics, a UUID v4 is the preferred user ID format. It is therefor necessary to provide a UUID of such type to `universal-analytics`. However you can force custom user ID, passing `strictCidFormat: false` in the options: +Starting with Universal Analytics, a UUID v4 is the preferred client ID format. It is therefor necessary to provide a UUID of such type to `universal-analytics`. However you can force custom client ID, passing `strictCidFormat: false` in the options: ```javascript -var visitor = ua('UA-XXXX-XX', 'CUSTOM_USERID_1', {strictCidFormat: false}); +var visitor = ua('UA-XXXX-XX', 'CUSTOM_CLIENTID_1', {strictCidFormat: false}); ``` If you want to use Google Analytics in https protocol, just include it in the options `https: true`, by default will use http: From 359a8ed83f13fb0aa8fa4788b19693ffdd8c6a7f Mon Sep 17 00:00:00 2001 From: Damian Krzeminski Date: Mon, 29 Jan 2018 21:41:45 -0700 Subject: [PATCH 12/13] add debug module --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index f77c7d5..97c8862 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "tracking" ], "dependencies": { + "debug": "^3.0.0", "request": "2.x", "uuid": "^3.0.0" }, From 0c7bdedb6655b131c8edd8f335e591a28bcb473d Mon Sep 17 00:00:00 2001 From: Damian Krzeminski Date: Mon, 29 Jan 2018 21:57:24 -0700 Subject: [PATCH 13/13] replace proprietary logging with DEBUG - remove `_log()` method - reimplement `visitor.debug()` to enable new debug module, add deprecation warning - remove tests for `visitor.debug()` --- README.md | 7 +++--- lib/index.js | 30 ++++++++++------------- test/index.js | 68 +++++++++------------------------------------------ 3 files changed, 28 insertions(+), 77 deletions(-) diff --git a/README.md b/README.md index 8fdd7c3..bb38b35 100644 --- a/README.md +++ b/README.md @@ -540,11 +540,10 @@ var visitor = ua.createFromSession(socket.handshake.session); # Debug mode -`universal-analytics` can be instructed to output information during tracking by enabling the debug mode: +`universal-analytics` is using the [`debug`](https://www.npmjs.com/package/debug) library. It can be instructed to output information during tracking by setting the `DEBUG` environment variable: -```javascript -var visitor = ua("UA-XXXX-XX").debug() -// … and so forth. +``` +DEBUG=universal-analytics ``` diff --git a/lib/index.js b/lib/index.js index e8b2388..04d3163 100644 --- a/lib/index.js +++ b/lib/index.js @@ -7,6 +7,8 @@ var utils = require("./utils"); var config = require("./config"); var url = require("url"); +var debug = require("debug")("universal-analytics"); + module.exports = init; @@ -102,9 +104,9 @@ module.exports.createFromSession = function (session) { Visitor.prototype = { - debug: function (debug) { - this.options.debug = arguments.length === 0 ? true : debug; - this._log("Logging enabled") + debug: function (d) { + debug.enabled = arguments.length === 0 ? true : d; + debug("visitor.debug() is deprecated: set DEBUG=universal-analytics to enable logging") return this; }, @@ -405,14 +407,14 @@ Visitor.prototype = { var self = this; var count = 1; var fn = fn || function () {}; - self._log("Sending " + self._queue.length + " tracking call(s)"); + debug("Sending %d tracking call(s)", self._queue.length); var getBody = function(params) { return params.map(function(x) { return querystring.stringify(x); }).join("\n"); } var onFinish = function (err) { - self._log("Finished sending tracking calls") + debug("Finished sending tracking calls") fn.call(self, err || null, count - 1); } @@ -432,7 +434,7 @@ Visitor.prototype = { var path = config.hostname + (useBatchPath ? config.batchPath :config.path); - self._log(count++ + ": " + JSON.stringify(params)); + debug("%d: %o", count++, params); var options = Object.assign({}, self.options.requestOptions, { body: getBody(params), @@ -472,11 +474,11 @@ Visitor.prototype = { this._queue.push(params); - if (this.options.debug) { + if (debug.enabled) { this._checkParameters(params); } - this._log("Enqueued " + type + " (" + JSON.stringify(params) + ")"); + debug("Enqueued %s (%o)", type, params); if (fn) { this.send(fn); @@ -487,7 +489,7 @@ Visitor.prototype = { _handleError: function (message, fn) { - this._log("Error: " + message) + debug("Error: %s", message) fn && fn.call(this, new Error(message)) return this; }, @@ -503,7 +505,7 @@ Visitor.prototype = { for (var i = 0; i < lastItem; i++) { id = utils.ensureValidCid(args[i]); if (id !== false) return id; - if (id != null) this._log("Warning! Invalid UUID format '" + args[i] + "'"); + if (id != null) debug("Warning! Invalid UUID format '%s'", args[i]); } } else { for (var i = 0; i < lastItem; i++) { @@ -521,7 +523,7 @@ Visitor.prototype = { }).length) { continue; } - this._log("Warning! Unsupported tracking parameter " + param + " (" + params[param] + ")"); + debug("Warning! Unsupported tracking parameter %s (%s)", param, params[param]); } }, @@ -546,12 +548,6 @@ Visitor.prototype = { return params; }, - - _log: function (message) { - this.options.debug && console.log("[universal-analytics] " + message); - }, - - _withContext: function (context) { var visitor = new Visitor(this.tid, this.cid, this.options, context, this._persistentParams); visitor._queue = this._queue; diff --git a/test/index.js b/test/index.js index 087a32a..5bc78cb 100644 --- a/test/index.js +++ b/test/index.js @@ -84,11 +84,11 @@ describe("ua", function () { tid: "UA-XXXXX-XX", cid: "custom-format-cid" }; - + var next = sinon.spy(uuid, 'v4') var visitor = ua(options); - + next.calledOnce.should.equal(true, "next() should've been called once") var generatedCid = next.returnValues[0] uuid.v4.restore() @@ -103,11 +103,11 @@ describe("ua", function () { cid: "custom-format-cid", strictCidFormat: false }; - + var next = sinon.spy(uuid, 'v4') var visitor = ua(options); - + next.called.should.equal(false, "next() should't be called") uuid.v4.restore() @@ -116,15 +116,15 @@ describe("ua", function () { describe("params", function () { - + var visitor; - + before(function () { var tid = "UA-XXXXX-XX"; var cid = uuid.v4(); visitor = ua(tid, cid); }); - + it('should not translate params', function(){ var params = { tid: 1, @@ -132,64 +132,20 @@ describe("ua", function () { somefake: 1, v: 'a' }; - - visitor._translateParams(params).should.eql(params); + + visitor._translateParams(params).should.eql(params); }) - - it('should match all parameters and each should be in the list of accepted', function(){ + + it('should match all parameters and each should be in the list of accepted', function(){ var res = visitor._translateParams(config.parametersMap); for (var i in res) { if (res.hasOwnProperty(i)) { res[i].should.equal(i); config.acceptedParameters.should.containEql(i); } - } + } }) - }); - - describe("#debug", function () { - - var log; - - before(function () { - log = sinon.stub(ua.Visitor.prototype, "_log") - }); - - after(function () { - log.restore(); - }); - - it("should enable debugging when invoked without arguments", function () { - var visitor = ua().debug() - - visitor.options.debug.should.equal(true); - - visitor.debug().should.equal(visitor, "should return itself") - - visitor.options.debug.should.equal(true, "A second #debug call should leave debugging enabled"); - }); - - it("should toggle debugging when invoked with a boolean arguments", function () { - var visitor = ua().debug(true) - - visitor.options.debug.should.equal(true); - - visitor.debug(false).should.equal(visitor, "should return itself") - - visitor.options.debug.should.equal(false); - }); - }); }); - - - - - - - - - -