revolunet / angular-google-analytics

Google Analytics tracking for your AngularJS apps
MIT License
652 stars 179 forks source link

How to set a custom page when sending an event? #196

Open muiscatron opened 7 years ago

muiscatron commented 7 years ago

I am tracking pageviews and events in my application. I used the regular expression method setRemoveRegExp to filter out sensitive information from page urls, and this worked OK. However, when I send events, the default page associated with the event does not have this filtering applied, and the sensitive information is still visible in the Pages report which is within the Google Analytics "Events" reporting section. I tried to apply a custom "page" property to the trackevent method call like this:

this.Analytics.trackEvent('category', 'action', '', value, false, { page: '/home' });

But it does not seem to work. When I look at network traffic in the browser debugger, it has the actual full URL populated in the "dl" parameter. The 'dp' parameter is being set correctly to the custom page property value. But this alone does not seem to prevent google analytics from recording the sensitive URL. Is there any way to have complete control of the page details when sending an Event?

muiscatron commented 7 years ago

Further information: When I call trackEvent and send the value parameter as null, dp property is never set in the collection api. If I set any value such as 0, the dp property is set using the page property value.

iamvenkat45 commented 7 years ago

+1