- Issue created by @kurttrowbridge
- 🇺🇸United States eojthebrave Minneapolis, MN
That's definitely weird. It's outputting the tag for me, albeit at the bottom of the page. See 🐛 In HTML Datalayer output snippet is at wrong location before body closing Active . And the lazy builder should "just work". Which I'm sure makes this especially frustrating.
I wonder if you've got another module installed that's somehow changing what happens in
hook_page_bottom()
? Like other modules that are trying to insert JS into the bottom of the page? Seems like a stretch ... but maybe.What theme are you using? If your theme overrides the html.html.twig template file can you confirm that it includes the
{{ page_bottom }}
variable? If that's missing than content added in hook_page_bottom() wouldn't be added to the page.And if it's not any of those things could you share the content of your datalayer config YAML file? That way I could try with the same configuration and see if it's something configuration related.
- 🇺🇸United States kurttrowbridge
Thanks for the quick reply! I had another chance to look further into this tonight, and unfortunately still don't have an answer. What I tried:
- Switching the
datalayer_page_bottom()
hook todatalayer_page_top()
- Uninstalling any other modules that implemented
hook_page_bottom()
(AMP, Mailchimp, Tour) - Removing my custom theme's
html.html.twig
template (even though it did have{{ page_bottom }}
included)
I've included my
datalayer.settings.yml
contents below._core: default_config_hash: N67AkcKPlikWJbwxABv6MSMpGuXe36qWZfH88pEzeqc add_page_meta: true output_terms: true output_fields: true remove_from_admin_routes: false lib_helper: false entity_meta: created: '0' langcode: '0' name: '0' status: '0' uid: '0' uuid: '0' vid: '0' enable_ia: false ia_depth: 3 ia_category_primary: primaryCategory ia_category_sub: subCategory vocabs: tags: tags column: '0' expose_user_details: '' expose_user_details_roles: authenticated: '0' content_editor: '0' social_media_editor: '0' administrator: '0' current_user_meta: name: '0' mail: '0' roles: '0' created: '0' access: '0' group: false expose_user_details_fields: false entity_title: entityTitle entity_type: entityType entity_bundle: entityBundle entity_identifier: entityId group_label: groupLabel drupal_language: drupalLanguage drupal_country: drupalCountry site_name: siteName key_replacements: - ''
And it case it's relevant, the
hook_datalayer_alter()
implementation through which I handle multivalue fields and a couple custom additions:/** * Implements hook_datalayer_alter(). */ function bridge_utilities_datalayer_alter(&$data_layer) { // Modify data layer for Tags. if (isset($data_layer['entityTaxonomy']['tags'])) { $data_layer['articleTags'] = implode('|', $data_layer['entityTaxonomy']['tags']); } // Modify data layer for Authors. if (isset($data_layer['field_author'])) { $authors = $data_layer['field_author']['value']; $author_names = []; foreach ($authors as $author) { if (!empty($author['label'])) { $author_names[] = $author['label']; } } $data_layer['articleAuthors'] = implode('|', $author_names); } // Modify data layer for publish date. if (isset($data_layer['entityCreated'])) { $data_layer['articleDate'] = date('Y-m-d', $data_layer['entityCreated']); } // Modify data layer for donation confirmation order ID and revenue. if (\Drupal::request()->get('uid') !== NULL) { $data_layer['order_id'] = \Drupal::request()->get('uid'); } if (\Drupal::request()->get('amount') !== NULL) { $data_layer['revenue'] = \Drupal::request()->get('amount'); } }
Thanks again!
- Switching the