diff --git a/utils/piwik/piwik.service.ts b/utils/piwik/piwik.service.ts index 7d546f1b..81c9c2f5 100644 --- a/utils/piwik/piwik.service.ts +++ b/utils/piwik/piwik.service.ts @@ -69,6 +69,22 @@ export class PiwikService { } + private doTrackEvent(properties: EnvProperties, title, siteId, pageURL, eventCategory, eventAction, eventName, eventValue = 0): Observable { + let ua = this.getUserAgent(); + let referrer = this.getReferrer(); + let piwikId = ((siteId != null) ? siteId : properties.piwikSiteId); + if (typeof location !== 'undefined' && piwikId) { + var url =`${properties.piwikBaseUrl}${piwikId}&rec=1&url=${encodeURIComponent(pageURL)}&action_name=${encodeURIComponent(title)}&e_c=${encodeURIComponent(eventCategory)}&e_a=${encodeURIComponent(eventAction)}&e_n=${encodeURIComponent(eventName)}&e_v=${encodeURIComponent(eventValue)}` + +((ua != null && ua.length > 0) ? ('&ua=' + StringUtils.URIEncode(ua)) : '') + + ((referrer != null && referrer.length > 0) ? ('&urlref=' + StringUtils.URIEncode(referrer)) : ''); + // console.log(trackingApiUrl) + console.log(url) + // return of(new Object()); // for testing + + return this.http.get(url, {responseType: 'blob'}); + } + } + private getUserAgent() { if (typeof navigator !== 'undefined') { return navigator.userAgent;