diff options
author | Jan <56178675+JE4GLE@users.noreply.github.com> | 2021-06-10 01:59:08 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-10 01:59:08 +0300 |
commit | 13f7d9a93ceeed5285161f4a38c92f15379c73ae (patch) | |
tree | 2b79823ce4c3d7186046050416bbb08e8ea5057e /js | |
parent | 63190d13da715767c845e5b3ab01d108956c6977 (diff) |
Add option to set page view id manually (#17655)
* Set custom pageView ID
* Semicolon
* Added method to the method list https://github.com/matomo-org/matomo/pull/17655#issuecomment-857370462
* configIdPageViewSetManually
Diffstat (limited to 'js')
-rw-r--r-- | js/piwik.js | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/js/piwik.js b/js/piwik.js index 875e5e1076..a957d43e84 100644 --- a/js/piwik.js +++ b/js/piwik.js @@ -63,7 +63,7 @@ setCustomVariable, getCustomVariable, deleteCustomVariable, storeCustomVariablesInCookie, setCustomDimension, getCustomDimension, deleteCustomVariables, deleteCustomDimension, setDownloadExtensions, addDownloadExtensions, removeDownloadExtensions, setDomains, setIgnoreClasses, setRequestMethod, setRequestContentType, setGenerationTimeMs, - setReferrerUrl, setCustomUrl, setAPIUrl, setDocumentTitle, getPiwikUrl, getMatomoUrl, getCurrentUrl, + setReferrerUrl, setCustomUrl, setAPIUrl, setDocumentTitle, setPageViewId, getPiwikUrl, getMatomoUrl, getCurrentUrl, setDownloadClasses, setLinkClasses, setCampaignNameKey, setCampaignKeywordKey, getConsentRequestsQueue, requireConsent, getRememberedConsent, hasRememberedConsent, isConsentRequired, @@ -2368,6 +2368,8 @@ if (typeof window.Matomo !== 'object') { domainHash, configIdPageView, + // Boolean indicating that a page view ID has been set manually + configIdPageViewSetManually = false, // we measure how many pageviews have been tracked so plugins can use it to eg detect if a // pageview was already tracked or not @@ -3894,7 +3896,9 @@ if (typeof window.Matomo !== 'object') { * Log the page view / visit */ function logPageView(customTitle, customData, callback) { - configIdPageView = generateUniqueId(); + if (!configIdPageViewSetManually) { + configIdPageView = generateUniqueId(); + } var request = getRequest('action_name=' + encodeWrapper(titleFixup(customTitle || configTitle)), customData, 'log'); @@ -5599,6 +5603,16 @@ if (typeof window.Matomo !== 'object') { }; /** + * Override PageView id + * + * @param string pageView + */ + this.setPageViewId = function (pageView) { + configIdPageView = pageView; + configIdPageViewSetManually = true; + }; + + /** * Set the URL of the Matomo API. It is used for Page Overlay. * This method should only be called when the API URL differs from the tracker URL. * |