зеркало из https://github.com/mozilla/bedrock.git
Update Pocket GTM Container (fixes #12624)
We have moved Pocket's GA4 property under the Mozilla Account. We use a lookup table in the GTM container to set measurement ID based on whether the hostname is production or not. If production, the measurement ID connects to getpocket.com - GA4 property. If not production, the measurement ID connects to getpocket.com - GA4 Testing property.
This commit is contained in:
Родитель
d3d0a74715
Коммит
cc6b4e2234
|
@ -13,7 +13,7 @@ DB_DOWNLOAD_IGNORE_GIT: "True"
|
||||||
DEBUG: "False"
|
DEBUG: "False"
|
||||||
DEV: "True"
|
DEV: "True"
|
||||||
GOOGLE_ANALYTICS_ID: "UA-370613-9"
|
GOOGLE_ANALYTICS_ID: "UA-370613-9"
|
||||||
GTM_CONTAINER_ID: "G-NFR9Y40GD3"
|
GTM_CONTAINER_ID: "GTM-P4LPJ42"
|
||||||
LOG_LEVEL: INFO
|
LOG_LEVEL: INFO
|
||||||
PROD_DETAILS_STORAGE: product_details.storage.PDDatabaseStorage
|
PROD_DETAILS_STORAGE: product_details.storage.PDDatabaseStorage
|
||||||
RUN_SUPERVISOR: "True"
|
RUN_SUPERVISOR: "True"
|
||||||
|
|
|
@ -11,7 +11,7 @@ const PocketAnalytics = {
|
||||||
loaded: false,
|
loaded: false,
|
||||||
|
|
||||||
loadGA: () => {
|
loadGA: () => {
|
||||||
// Google Tag Manager used to load GA4 (gtag.js)
|
// Google Tag Manager used to load GA4 (gtm.js)
|
||||||
const GTM_CONTAINER_ID = document
|
const GTM_CONTAINER_ID = document
|
||||||
.getElementsByTagName('html')[0]
|
.getElementsByTagName('html')[0]
|
||||||
.getAttribute('data-gtm-container-id');
|
.getAttribute('data-gtm-container-id');
|
||||||
|
@ -21,15 +21,19 @@ const PocketAnalytics = {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (GTM_CONTAINER_ID) {
|
if (GTM_CONTAINER_ID) {
|
||||||
const gaScript = document.createElement('script');
|
(function (w, d, s, l, i) {
|
||||||
gaScript.async = 'true';
|
w[l] = w[l] || [];
|
||||||
gaScript.type = 'text/javascript';
|
w[l].push({
|
||||||
gaScript.src = `https://www.googletagmanager.com/gtag/js?id=${GTM_CONTAINER_ID}`;
|
'gtm.start': new Date().getTime(),
|
||||||
const pageScript = document.getElementsByTagName('script')[0];
|
event: 'gtm.js'
|
||||||
pageScript.parentNode.insertBefore(gaScript, pageScript);
|
});
|
||||||
|
const f = d.getElementsByTagName(s)[0],
|
||||||
window.gtag('js', new Date());
|
j = d.createElement(s),
|
||||||
window.gtag('config', GTM_CONTAINER_ID);
|
dl = l !== 'dataLayer' ? '&l=' + l : '';
|
||||||
|
j.async = true;
|
||||||
|
j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
|
||||||
|
f.parentNode.insertBefore(j, f);
|
||||||
|
})(window, document, 'script', 'dataLayer', [GTM_CONTAINER_ID]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Google Universal Analytics (analytics.js)
|
// Google Universal Analytics (analytics.js)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче