зеркало из 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"
|
||||
DEV: "True"
|
||||
GOOGLE_ANALYTICS_ID: "UA-370613-9"
|
||||
GTM_CONTAINER_ID: "G-NFR9Y40GD3"
|
||||
GTM_CONTAINER_ID: "GTM-P4LPJ42"
|
||||
LOG_LEVEL: INFO
|
||||
PROD_DETAILS_STORAGE: product_details.storage.PDDatabaseStorage
|
||||
RUN_SUPERVISOR: "True"
|
||||
|
|
|
@ -11,7 +11,7 @@ const PocketAnalytics = {
|
|||
loaded: false,
|
||||
|
||||
loadGA: () => {
|
||||
// Google Tag Manager used to load GA4 (gtag.js)
|
||||
// Google Tag Manager used to load GA4 (gtm.js)
|
||||
const GTM_CONTAINER_ID = document
|
||||
.getElementsByTagName('html')[0]
|
||||
.getAttribute('data-gtm-container-id');
|
||||
|
@ -21,15 +21,19 @@ const PocketAnalytics = {
|
|||
};
|
||||
|
||||
if (GTM_CONTAINER_ID) {
|
||||
const gaScript = document.createElement('script');
|
||||
gaScript.async = 'true';
|
||||
gaScript.type = 'text/javascript';
|
||||
gaScript.src = `https://www.googletagmanager.com/gtag/js?id=${GTM_CONTAINER_ID}`;
|
||||
const pageScript = document.getElementsByTagName('script')[0];
|
||||
pageScript.parentNode.insertBefore(gaScript, pageScript);
|
||||
|
||||
window.gtag('js', new Date());
|
||||
window.gtag('config', GTM_CONTAINER_ID);
|
||||
(function (w, d, s, l, i) {
|
||||
w[l] = w[l] || [];
|
||||
w[l].push({
|
||||
'gtm.start': new Date().getTime(),
|
||||
event: 'gtm.js'
|
||||
});
|
||||
const f = d.getElementsByTagName(s)[0],
|
||||
j = d.createElement(s),
|
||||
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)
|
||||
|
|
Загрузка…
Ссылка в новой задаче