mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Revert "FIX: prevents google to track certain pages (#7455)"
This reverts commit c863e62998
.
This commit is contained in:
parent
587cfd4545
commit
726dd0fe37
@ -24,8 +24,6 @@ export default {
|
|||||||
// if it is present
|
// if it is present
|
||||||
if (typeof window._gaq !== "undefined") {
|
if (typeof window._gaq !== "undefined") {
|
||||||
appEvents.on("page:changed", data => {
|
appEvents.on("page:changed", data => {
|
||||||
if (!this._shouldTrack(data.currentRouteName)) return;
|
|
||||||
|
|
||||||
window._gaq.push(["_set", "title", data.title]);
|
window._gaq.push(["_set", "title", data.title]);
|
||||||
window._gaq.push(["_trackPageview", data.url]);
|
window._gaq.push(["_trackPageview", data.url]);
|
||||||
});
|
});
|
||||||
@ -35,33 +33,13 @@ export default {
|
|||||||
// Also use Universal Analytics if it is present
|
// Also use Universal Analytics if it is present
|
||||||
if (typeof window.ga !== "undefined") {
|
if (typeof window.ga !== "undefined") {
|
||||||
appEvents.on("page:changed", data => {
|
appEvents.on("page:changed", data => {
|
||||||
if (!this._shouldTrack(data.currentRouteName)) return;
|
|
||||||
|
|
||||||
window.ga("send", "pageview", { page: data.url, title: data.title });
|
window.ga("send", "pageview", { page: data.url, title: data.title });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// And Google Tag Manager too
|
// And Google Tag Manager too
|
||||||
if (typeof window.dataLayer !== "undefined") {
|
if (typeof window.dataLayer !== "undefined") {
|
||||||
appEvents.on("page:changed", data => {
|
appEvents.on("page:changed", googleTagManagerPageChanged);
|
||||||
if (!this._shouldTrack(data.currentRouteName)) return;
|
|
||||||
|
|
||||||
googleTagManagerPageChanged(data);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
_shouldTrack(routeName) {
|
|
||||||
const excludedRoutes = [
|
|
||||||
"adminSiteText.index",
|
|
||||||
"adminSiteText.edit",
|
|
||||||
"adminSiteSettingsCategory"
|
|
||||||
];
|
|
||||||
|
|
||||||
if (excludedRoutes.includes(routeName)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user