diff options
Diffstat (limited to 'js/piwik.js')
-rw-r--r-- | js/piwik.js | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/js/piwik.js b/js/piwik.js index 4783eba905..b961361cbc 100644 --- a/js/piwik.js +++ b/js/piwik.js @@ -2277,6 +2277,9 @@ if (typeof window.Piwik !== 'object') { // Custom Variables names and values are each truncated before being sent in the request or recorded in the cookie customVariableMaximumLength = 200, + // Ecommerce product view + ecommerceProductView = {}, + // Ecommerce items ecommerceItems = {}, @@ -3682,6 +3685,13 @@ if (typeof window.Piwik !== 'object') { // we deleted all keys from custom data } + // product page view + for (i in ecommerceProductView) { + if (Object.prototype.hasOwnProperty.call(ecommerceProductView, i)) { + request += '&' + i + '=' + encodeWrapper(ecommerceProductView[i]); + } + } + // custom dimensions for (i in customDimensions) { if (Object.prototype.hasOwnProperty.call(customDimensions, i)) { @@ -6309,8 +6319,6 @@ if (typeof window.Piwik !== 'object') { /** * Used to record that the current page view is an item (product) page view, or a Ecommerce Category page view. * This must be called before trackPageView() on the product/category page. - * It will set 3 custom variables of scope "page" with the SKU, Name and Category for this page view. - * Note: Custom Variables of scope "page" slots 3, 4 and 5 will be used. * * On a category page, you can set the parameter category, and set the other parameters to empty string or false * @@ -6323,6 +6331,8 @@ if (typeof window.Piwik !== 'object') { * @param float price Item's display price, not use in standard Piwik reports, but output in API product reports. */ this.setEcommerceView = function (sku, name, category, price) { + ecommerceProductView = {}; + if (isNumberOrHasLength(category)) { category = String(category); } @@ -6332,10 +6342,12 @@ if (typeof window.Piwik !== 'object') { category = windowAlias.JSON.stringify(category); } - customVariablesPage[5] = ['_pkc', category]; + var param = '_pkc'; + ecommerceProductView[param] = category; if (isDefined(price) && price !== null && price !== false && String(price).length) { - customVariablesPage[2] = ['_pkp', price]; + param = '_pkp'; + ecommerceProductView[param] = price; } // On a category page, do not track Product name not defined @@ -6344,14 +6356,16 @@ if (typeof window.Piwik !== 'object') { } if (isNumberOrHasLength(sku)) { - customVariablesPage[3] = ['_pks', sku]; + param = '_pks'; + ecommerceProductView[param] = sku; } if (!isNumberOrHasLength(name)) { name = ""; } - customVariablesPage[4] = ['_pkn', name]; + param = '_pkn'; + ecommerceProductView[param] = name; }; /** |