Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to add Google Tag Manager without hacking default.html #4855

Open
lsolesen opened this issue May 23, 2024 · 1 comment
Open

Comments

@lsolesen
Copy link
Contributor

What happened?

  • Minimal Mistakes version: 4.26.1
  • Ruby gem or remote theme version:
  • Jekyll version:
  • Git repository URL:
  • Hosted on GitHub Pages (if yes provide URL to site):
  • Operating system:

Expected behavior

Enable a way to include Google Tag Manager without having to hack default.html.

Right now you need to:

---
---

<!doctype html>
{% include copyright.html %}
<html lang="{{ site.locale | slice: 0,2 | default: "en" }}" class="no-js">
  <head>
{% if jekyll.environment == 'production' %}
{% comment %}
<script async src="https://www.googleoptimize.com/optimize.js?id=OPT-T4ZK4CX"></script>
{% endcomment %}
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
  new Date().getTime(),event:'gtm.js'});var 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-XXX');</script>
  <!-- End Google Tag Manager -->
{% endif %}
    {% include head.html %}
    {% include head/custom.html %}
  </head>

  <body class="layout--{{ page.layout | default: layout.layout }}{% if page.classes or layout.classes %}{{ page.classes | default: layout.classes | join: ' ' | prepend: ' ' }}{% endif %}">
{% if jekyll.environment == 'production' %}
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXX"
  height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
{% endif %}
    {% include_cached skip-links.html %}
    {% include_cached masthead.html %}

    <div class="initial-content">
      {{ content }}
      {% include after-content.html %}
    </div>

    {% if site.search == true %}
      <div class="search-content">
        {% include_cached search/search_form.html %}
      </div>
    {% endif %}

    <div id="footer" class="page__footer">
      <footer>
        {% include footer/custom.html %}
        {% include_cached footer.html %}
      </footer>
    </div>

    {% include scripts.html %}

  </body>
</html>

Would be nice to be able to add Tag Manager without having to modify default.html, if possible.

Steps to reproduce the behavior

See above example.

Other

See above example.

@iBug
Copy link
Collaborator

iBug commented May 23, 2024

There's {% include head/custom.html %} so you can always override that file instead of default.html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants