-
Notifications
You must be signed in to change notification settings - Fork 1
Do Not Track in JavaScript
Mark Howells-Mead edited this page Oct 9, 2019
·
1 revision
Examples for Google Analytics and Matomo (Piwik)
var trackSearchRequest = function(){
if(!('doNotTrack' in navigator) || navigator.doNotTrack === 0 || navigator.doNotTrack === false){
// Google Analytics
if (ga && typeof ga === 'function') {
ga('send', 'event', {
eventCategory: 'Search',
eventAction: 'search_request',
eventLabel: my_search_term
});
}
// Matomo
if (_paq && typeof _paq === 'object') {
_paq.push([
'trackEvent',
'Search',
'search_request',
my_search_term
]);
}
}
};
Mark Howells-Mead | https://permanenttourist.ch and https://sayhello.ch/ | Wiki since 2016
Use this code freely, widely and for free. Provision of this code provides and implies no guarantee.
Please respect the GPL v3 licence, which is available via http://www.gnu.org/licenses/gpl-3.0.html