Skip to content

A platform for community discussion. Free, open, simple.

Revert "FIX: prevents google to track certain pages (#7455)"

Joffrey JAFFEUX726dd0fe3747
diff --git a/app/assets/javascripts/discourse/initializers/page-tracking.js.es6 b/app/assets/javascripts/discourse/initializers/page-tracking.js.es6
index 01a13c9c81b..84a9d51de79 100644
--- a/app/assets/javascripts/discourse/initializers/page-tracking.js.es6
+++ b/app/assets/javascripts/discourse/initializers/page-tracking.js.es6
@@ -24,8 +24,6 @@ export default {
// if it is present
if (typeof window._gaq !== "undefined") {
appEvents.on("page:changed", data => {
- if (!this._shouldTrack(data.currentRouteName)) return;
-
window._gaq.push(["_set", "title", data.title]);
window._gaq.push(["_trackPageview", data.url]);
});
@@ -35,33 +33,13 @@ export default {
// Also use Universal Analytics if it is present
if (typeof window.ga !== "undefined") {
appEvents.on("page:changed", data => {
- if (!this._shouldTrack(data.currentRouteName)) return;
-
window.ga("send", "pageview", { page: data.url, title: data.title });
});
}
// And Google Tag Manager too
if (typeof window.dataLayer !== "undefined") {
- appEvents.on("page:changed", data => {
- if (!this._shouldTrack(data.currentRouteName)) return;
-
- googleTagManagerPageChanged(data);
- });
+ appEvents.on("page:changed", googleTagManagerPageChanged);
}
- },
-
- _shouldTrack(routeName) {
- const excludedRoutes = [
- "adminSiteText.index",
- "adminSiteText.edit",
- "adminSiteSettingsCategory"
- ];
-
- if (excludedRoutes.includes(routeName)) {
- return false;
- }
-
- return true;
}
};