Andrew Fletcher published: 19 August 2023 (updated) 21 August 2023 3 minutes read
On most of the sites I'm running the Google analytics ID is appearing. Therefore, tracking and capturing data. All except one!
Discovering where Google ID and Google Tag ID were on a client's site... or not in this situation. Yes that's correct, for some reason the analytics IDs aren't appearing. Zip, zero... nothing.
Looking on this site, Google tag Manager positions the tag ID in the following lines of code
<link rel="stylesheet" media="all" href="/sites/default/files/css/css_G4ITzbTP975nnq8RraxB-6CK9bFsPJWsTm5sBtIPMqU.css?delta=0&language=en&theme=bales&include=eJyNj1GOwzAIRC_k2EeKqE2QW2JcwJvN7Ru16U-1WvVnmDcagYBSXKDtCU4TF5XmwXZzXNMFDEMWxXS9D9Q9SstnUHR04NhVSNEsXIDRErEcZjLfuTb6CLPW7nbusymL3CoGHPPLHWPtXOE4kf4Kv2_OBRcY7IFEiHF2oESHfHKEK_yGn4qbpafGVcpgDAtkdEtbLYT-pvPjF8Wi0otsbfqvRNhQgR9pUIrI" />
<link rel="stylesheet" media="all" href="/sites/default/files/css/css_IWQEngTWxUSxnOhb5FT_9Boc0z5ai8sCiuWmBeeq_xI.css?delta=1&language=en&theme=bales&include=eJyNj1GOwzAIRC_k2EeKqE2QW2JcwJvN7Ru16U-1WvVnmDcagYBSXKDtCU4TF5XmwXZzXNMFDEMWxXS9D9Q9SstnUHR04NhVSNEsXIDRErEcZjLfuTb6CLPW7nbusymL3CoGHPPLHWPtXOE4kf4Kv2_OBRcY7IFEiHF2oESHfHKEK_yGn4qbpafGVcpgDAtkdEtbLYT-pvPjF8Wi0otsbfqvRNhQgR9pUIrI" />
<script type="application/json" data-drupal-selector="drupal-settings-json">
{
"path": {
"baseUrl": "/",
"scriptPath": null,
"pathPrefix": "",
"currentPath": "knowledge-hub",
"currentPathIsAdmin": false,
"isFront": true,
"currentLanguage": "en"
},
"pluralDelimiter": "\u0003",
"suppressDeprecationErrors": true,
"ajaxPageState": {
"libraries": "addtoany/addtoany.front,bales/global-scripts,bales/global-styling,eu_cookie_compliance/eu_cookie_compliance_default,facets/drupal.facets.dropdown-widget,facets/drupal.facets.general,google_tag/gtag,google_tag/gtag.ajax,system/base,views/views.module",
"theme": "bales",
"theme_token": null
},
"ajaxTrustedUrl": { "/knowledge-hub": true },
"gtag": {
"tagId": "UA-{ID-REFERENCE}",
"otherIds": ["G-{ID-REFERENCE}", "GT-{ID-REFERENCE}"],
"events": [],
"additionalConfigInfo": []
},
"eu_cookie_compliance": {
"cookie_policy_version": "1.0.0",
"popup_enabled": true,
"popup_agreed_enabled": false,
"popup_hide_agreed": false,
"popup_clicking_confirmation": false,
"popup_scrolling_confirmation": false,
"popup_html_info": "\u003Cdiv aria-labelledby=\u0022popup-text\u0022 class=\u0022eu-cookie-compliance-banner eu-cookie-compliance-banner-info eu-cookie-compliance-banner--opt-in\u0022\u003E\n \u003Cdiv class=\u0022popup-content info eu-cookie-compliance-content\u0022\u003E\n \u003Cdiv id=\u0022popup-text\u0022 class=\u0022eu-cookie-compliance-message\u0022 role=\u0022document\u0022\u003E\n \u003Ch2\u003EWe use cookies on this site to enhance your user experience.\u003C/h2\u003E\n\u003Cp\u003EBy clicking the Accept button, you agree to us doing so.\u003C/p\u003E\n\n \u003C/div\u003E\n\n \n \u003Cdiv id=\u0022popup-buttons\u0022 class=\u0022eu-cookie-compliance-buttons\u0022\u003E\n \u003Cbutton type=\u0022button\u0022 class=\u0022agree-button eu-cookie-compliance-secondary-button\u0022\u003EAccept\u003C/button\u003E\n \u003Cbutton type=\u0022button\u0022 class=\u0022decline-button eu-cookie-compliance-default-button\u0022\u003ENo, thanks\u003C/button\u003E\n \u003C/div\u003E\n \u003C/div\u003E\n\u003C/div\u003E",
"use_mobile_message": false,
"mobile_popup_html_info": "\u003Cdiv aria-labelledby=\u0022popup-text\u0022 class=\u0022eu-cookie-compliance-banner eu-cookie-compliance-banner-info eu-cookie-compliance-banner--opt-in\u0022\u003E\n \u003Cdiv class=\u0022popup-content info eu-cookie-compliance-content\u0022\u003E\n \u003Cdiv id=\u0022popup-text\u0022 class=\u0022eu-cookie-compliance-message\u0022 role=\u0022document\u0022\u003E\n \n \u003C/div\u003E\n\n \n \u003Cdiv id=\u0022popup-buttons\u0022 class=\u0022eu-cookie-compliance-buttons\u0022\u003E\n \u003Cbutton type=\u0022button\u0022 class=\u0022agree-button eu-cookie-compliance-secondary-button\u0022\u003EAccept\u003C/button\u003E\n \u003Cbutton type=\u0022button\u0022 class=\u0022decline-button eu-cookie-compliance-default-button\u0022\u003ENo, thanks\u003C/button\u003E\n \u003C/div\u003E\n \u003C/div\u003E\n\u003C/div\u003E",
"mobile_breakpoint": 768,
"popup_html_agreed": false,
"popup_use_bare_css": false,
"popup_height": "auto",
"popup_width": "100%",
"popup_delay": 1000,
"popup_link": "/",
"popup_link_new_window": true,
"popup_position": false,
"fixed_top_position": true,
"popup_language": "en",
"store_consent": true,
"better_support_for_screen_readers": false,
"cookie_name": "",
"reload_page": false,
"domain": "",
"domain_all_sites": false,
"popup_eu_only": false,
"popup_eu_only_js": false,
"cookie_lifetime": 100,
"cookie_session": 0,
"set_cookie_session_zero_on_disagree": 0,
"disagree_do_not_show_popup": false,
"method": "opt_in",
"automatic_cookies_removal": true,
"allowed_cookies": "",
"withdraw_markup": "\u003Cbutton type=\u0022button\u0022 class=\u0022eu-cookie-withdraw-tab\u0022\u003EPrivacy settings\u003C/button\u003E\n\u003Cdiv aria-labelledby=\u0022popup-text\u0022 class=\u0022eu-cookie-withdraw-banner\u0022\u003E\n \u003Cdiv class=\u0022popup-content info eu-cookie-compliance-content\u0022\u003E\n \u003Cdiv id=\u0022popup-text\u0022 class=\u0022eu-cookie-compliance-message\u0022 role=\u0022document\u0022\u003E\n \u003Ch2\u003EWe use cookies on this site to enhance your user experience.\u003C/h2\u003E\n\u003Cp\u003EYou have given your consent for us to set cookies.\u003C/p\u003E\n\n \u003C/div\u003E\n \u003Cdiv id=\u0022popup-buttons\u0022 class=\u0022eu-cookie-compliance-buttons\u0022\u003E\n \u003Cbutton type=\u0022button\u0022 class=\u0022eu-cookie-withdraw-button \u0022\u003EWithdraw consent\u003C/button\u003E\n \u003C/div\u003E\n \u003C/div\u003E\n\u003C/div\u003E",
"withdraw_enabled": false,
"reload_options": 0,
"reload_routes_list": "",
"withdraw_button_on_info_popup": false,
"cookie_categories": [],
"cookie_categories_details": [],
"enable_save_preferences_button": true,
"cookie_value_disagreed": "0",
"cookie_value_agreed_show_thank_you": "1",
"cookie_value_agreed": "2",
"containing_element": "body",
"settings_tab_enabled": false,
"olivero_primary_button_classes": "",
"olivero_secondary_button_classes": "",
"close_button_action": "close_banner",
"open_by_default": true,
"modules_allow_popup": true,
"hide_the_banner": false,
"geoip_match": true
},
"facets": {
"dropdown_widget": {
"knowledge_tags": { "facet-default-option-label": "Tags" }
}
}
}
</script>
In the code dump above exists the following text
"gtag":{"tagId":"UA-{ID-REFERENCE}","otherIds":["G-{ID-REFERENCE}","GT-{ID-REFERENCE}"]
Whereas, on the site with the missing Google reference, it's appearing as
<script type="application/json" data-drupal-selector="drupal-settings-json">
{
"path": {
"baseUrl": "/",
"scriptPath": null,
"pathPrefix": "",
"currentPath": "node",
"currentPathIsAdmin": false,
"isFront": true,
"currentLanguage": "en"
},
"pluralDelimiter": "\u0003",
"suppressDeprecationErrors": true,
"ajaxPageState": {
"libraries": "admin_toolbar/toolbar.tree,admin_toolbar/toolbar.tree.hoverintent,admin_toolbar_search/search,admin_toolbar_tools/toolbar.icon,contextual/drupal.contextual-links,contextual/drupal.contextual-toolbar,core/drupal.active-link,devel/devel-toolbar,{theme}/fonts,{theme}/global-scripts,{theme}/global-styling,shortcut/drupal.shortcut,system/base,toolbar/toolbar,toolbar/toolbar.escapeAdmin,tour/tour,user/drupal.user.icons",
"theme": "{theme}",
"theme_token": null
},
"ajaxTrustedUrl": [],
"toolbar": {
"breakpoints": {
"toolbar.narrow": "only screen and (min-width: 16.5em)",
"toolbar.standard": "only screen and (min-width: 38.125em)",
"toolbar.wide": "only screen and (min-width: 61em)"
},
"subtreesHash": "_t3dUhxipIt1v7N4nvfxGeuK4APH8xqMwY1AbmapV0I"
},
"adminToolbarSearch": { "loadExtraLinks": true }
}
</script>
Related articles
Andrew Fletcher
•
30 Apr 2024
Best Practices for Configuring Twig Debug Settings in Drupal 10
When developing with Drupal 10, it's crucial to maintain an environment that is both secure and efficient. One of the important aspects of this setup involves the management of Twig template debugging. Proper configuration of these settings helps prevent unnecessary performance degradation and...
Andrew Fletcher
•
27 Apr 2024
Streamlined Drupal 10 Deployment: Best Practices for Stability and Security
Have you ever walked into a situation at work and just wondered how everything still runs smoothly? I mean, there are deployments with so many fail-safes stacked on a shaky foundation that it's almost a miracle they work at all. The real trick is gently nudging the team toward accepting change to...
Andrew Fletcher
•
27 Apr 2024
TypeError: Cannot assign null to property Drupal\views\Plugin\views\argument\ArgumentPluginBase::$operator of type string
I'm getting the following errorTypeError: Cannot assign null to property Drupal\views\Plugin\views\argument\ArgumentPluginBase::$operator of type string in Drupal\views\Plugin\views\argument\ArgumentPluginBase->unpackArgumentValue() (line 1302 of...