From 36310f7a67df641dd42fca6148309fdd916e6724 Mon Sep 17 00:00:00 2001 From: Ismail Habib Muhammad Date: Mon, 14 Mar 2016 11:30:15 +0100 Subject: [PATCH] Added an option to not include module.name in the URL. --- src/GoogleAnalytics/MasterPageTracker.xml | 6 +++- .../widget/MasterPageTracker.js | 28 +++++++++++-------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/GoogleAnalytics/MasterPageTracker.xml b/src/GoogleAnalytics/MasterPageTracker.xml index 3e9115b..83a6573 100644 --- a/src/GoogleAnalytics/MasterPageTracker.xml +++ b/src/GoogleAnalytics/MasterPageTracker.xml @@ -29,6 +29,11 @@ Behavior The prefix that you want to be displayed in the Google Analytics. It is especially useful if you are using this widget in different apps while using the same tracked code (UA-XX-XXX) + + Include module and page name + Behavior + The value determines whether the submitted url to Google Analytics will include both the module and page name + Active Behavior @@ -76,4 +81,3 @@ - diff --git a/src/GoogleAnalytics/widget/MasterPageTracker.js b/src/GoogleAnalytics/widget/MasterPageTracker.js index c21f818..8d41cb4 100644 --- a/src/GoogleAnalytics/widget/MasterPageTracker.js +++ b/src/GoogleAnalytics/widget/MasterPageTracker.js @@ -85,22 +85,28 @@ define("GoogleAnalytics/widget/MasterPageTracker", [ })); } }, - + _buildFullPath: function(prefix, includePageName, oriMendixPath) { + if (includePageName) { + var pageExtension = ".page.xml"; + var path = oriMendixPath.substr(0, oriMendixPath.length - pageExtension.length); + return prefix + "/" + path; + } else { + return prefix; + } + }, _addPage: function () { logger.debug(this.id + "._addPage"); - var pageExtension = ".page.xml"; - var oriPath = this.mxform.path; - var path = oriPath.substr(0, oriPath.length - pageExtension.length); if (typeof this.prefix !== "undefined" && this.prefix !== "") { - path = this.prefix + "/" + path; + this._replaceTags(this.prefix, lang.hitch(this, function(text) { + var path = this._buildFullPath(text, this.includePageName, this.mxform.path) + ga("send", { + "hitType": "pageview", + "page": path, + "title": this.mxform.title + }); + })); } - ga("send", { - "hitType": "pageview", - "page": path, - "title": this.mxform.title - }); } - }); });