How can I install GTM on Ella theme without a body tag?

Topic summary

A user is attempting to install Google Tag Manager (GTM) on a Shopify store using the Ella theme but cannot locate the <body> tag in their theme.liquid file to insert the required GTM code.

The Problem:

  • GTM installation requires placing code immediately after the opening <body> tag
  • The theme.liquid code appears obfuscated or reversed, making the <body> tag difficult to identify
  • The provided code snippet shows unusual formatting with reversed text patterns

Proposed Solution:
Another user asks for clarification on whether the GTM code should be placed after the opening <body> tag or before the closing </body> tag, and provides screenshots showing both potential placement locations.

Current Status:
The original poster acknowledges the response and indicates they will attempt the suggested approach. The discussion remains open pending confirmation of whether the solution works.

Summarized with AI on November 13. AI used: claude-sonnet-4-5-20250929.

Hi there,

I’d like to install GTM on my Shopify store, but I’ve encountered an issue. I can’t locate the tag in my theme.liquid code, making it difficult for me to determine where to insert the following code (as per GTM’s guide, it needs to be placed right behind ). Here is the code from my theme. Could someone please assist me in finding a solution?

<!doctype html>
<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]><html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]><html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if IE 9 ]><html class="ie9 no-js"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class="no-js"> <!--<![endif]-->
<head> 

<style>
@media (min-width: 990px) {
.groups-btn .shopify-payment-button {
    width: calc(100% - 230px);
    float: right;
    clear: unset !important;
    max-width: 220px;
}
.product-shop .shopify-payment-button button.shopify-payment-button__button {
    padding-bottom: 11px !important;
}
}
</style>
    <script src='{{ 'product_boom_points.js' | asset_url }}' defer='defer' ></script> 
    <script id='bm_product_variants' type='application/json'>
        {{ product.variants | json }}
    </script>
    <script id='bm_product_selected_or_first_available_variant' type='application/json'>
        {{ product.selected_or_first_available_variant | json }}
    </script>
    <script id='bm_product_metafields' type='application/json'>
        {{ shop.metafields.boom-sealapps-app.effective-time | json }}
    </script> 
  
<script>
(function(g,e,o,t,a,r,ge,tl,y,s){
t=g.getElementsByTagName(e)[0];y=g.createElement(e);y.async=true;
y.src='https://g9508048080.co/gr?id=-Mtk_UF0QbxgcmjV-hD0&refurl='+g.referrer+'&winurl='+encodeURIComponent(window.location);
t.parentNode.insertBefore(y,t);
})(document,'script');
</script>
  
<script>
(function(g,e,o,t,a,r,ge,tl,y,s){
g.getElementsByTagName(o)[0].insertAdjacentHTML('afterbegin','<style id="georedirect1599472228848style">body{opacity:0.0 !important;}</style>');
s=function(){g.getElementById('georedirect1599472228848style').innerHTML='body{opacity:1.0 !important;}';};
t=g.getElementsByTagName(o)[0];y=g.createElement(e);y.async=true;
y.src='https://g10300385420.co/gr?id=-MGbyK_9sp83HF0aM-Pk&refurl='+g.referrer+'&winurl='+encodeURIComponent(window.location);
t.parentNode.insertBefore(y,t);y.onerror=function(){s()};
georedirect1599472228848loaded=function(redirect){var to=0;if(redirect){to=5000};
setTimeout(function(){s();},to)};
})(document,'script','head');
</script>
  
<script>
(function(g,e,o,t,a,r,ge,tl,y,s){
g.getElementsByTagName(o)[0].insertAdjacentHTML('afterbegin','<style id="georedirect1599036544038style">body{opacity:0.0 !important;}</style>');
s=function(){g.getElementById('georedirect1599036544038style').innerHTML='body{opacity:1.0 !important;}';};
t=g.getElementsByTagName(o)[0];y=g.createElement(e);y.async=true;
y.src='https://g792337342.co/gr?id=-MGD-KD5l5CiL6PMq-oR&refurl='+g.referrer+'&winurl='+encodeURIComponent(window.location);
t.parentNode.insertBefore(y,t);y.onerror=function(){s()};
georedirect1599036544038loaded=function(redirect){var to=0;if(redirect){to=5000};
setTimeout(function(){s();},to)};
})(document,'script','head');
</script>

  <!-- Basic page needs ================================================== -->
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	
  <!-- Title and description ================================================== -->
  <title>
  {{ page_title }}{% if current_tags %} – tagged "{{ current_tags | join: ', ' }}"{% endif %}{% if current_page != 1 %} – Page {{ current_page }}{% endif %}{% unless page_title contains shop.name %} – {{ shop.name }}{% endunless %}
  </title>

  {% if page_description %}
  <meta name="description" content="{{ page_description | escape | split: '[/countdown]' | last | strip_html }}">
  {% endif %}

  <!-- Product meta ================================================== -->
  {% render 'fb-open-graph-tags' %}
  {% render 'twitter-card' %}

  <!-- Helpers ================================================== -->
  <link rel="canonical" href="{{ canonical_url }}">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0, minimal-ui">
  
  <!-- Favicon -->
  {% if settings.favicon != blank %}
  <link rel="shortcut icon" href="{{ settings.favicon | img_url: '32x32' }}" type="image/png">
  {% endif %}
 
   <!-- fonts -->
  {% render 'head_fonts' %}
  
  <!-- Styles -->
  {% render 'head_styles' %}
  
   <!-- Scripts -->
  {% render 'head_scripts' %}

  <!-- Header hook for plugins ================================ -->
  {{ content_for_header }}
{%- render 'bold-common' -%}

  <!--[if lt IE 9]>
  {{ '//html5shiv.googlecode.com/svn/trunk/html5.js' | script_tag }}
  <![endif]-->

  {% comment %}
    If you store has customers disabled, you can remove the following JS file
  {% endcomment %}
  
  {% if template contains 'customers' %}
    {{ 'shopify_common.js' | shopify_asset_url | script_tag }}
    {{ 'customer_area.js'  | shopify_asset_url | script_tag }}
    {% endif %}

  {% render 'linked-options' %}
{% render 'weglot_hreftags' %}
{% render 'weglot_switcher' %}
 
{% render 'pagefly-header' %}
 
  {% include 'shogun-head' %}

                  {% include 'bss-product-labels-configs' %}
                        {% include "loyaltylion" %}

</head>
   

    {% if settings.layout_body == 'full' %}    
        {%- assign layout_class = 'body-full' -%}   
    {% elsif settings.layout_body == 'boxed' %} 
        {%- assign layout_class = 'body-boxed' -%} 
    {% endif %}

    {% if settings.header_layout == 'vertical' %}
        {%- assign header_class = 'header-vertical-tpl' -%} 
    {% endif %}

<body data-url-lang="{{ routes.cart_url }}" id="{{ page_title | handle }}" class="{{ header_class }} {{ layout_class }} {% if customer %}customer-logged-in {% endif %}template-{{ template | replace: '.', ' ' | truncatewords: 1, '' | handle }}">{% capture the_snippet_content %}{% render 'socialshopwave-helper' %}{% endcapture %}{% unless the_snippet_content contains 'Liquid error' %}{{ the_snippet_content }}{% endunless %}
  	{% if template contains 'index' %}  
    <h1 style="display: none">{{ page_title | split: '|' | first }}</h1>
    {% endif %}
    {% render 'wrapper-header' %}   

    {% if settings.header_layout == 'vertical' %}
    <div class="flex-nav-vertical">
    {% endif %}    

    {% if settings.header_layout == 'vertical' %}
    {% section 'navigation-vertical-menu' %}
    {% endif %}
	{% render 'scheme' %}

    <div class="wrapper-container wrapper-body">	
        <main class="main-content" role="main">      
            {{ content_for_layout }}
        </main>    
            
        {% if settings.footer_layout == 'default' %}        
        {% section 'footer' %}
        {% elsif settings.footer_layout == 'parallax' %}
        {% section 'footer-parallax' %}
        {% elsif settings.footer_layout == '02' %}
        {% section 'footer-2' %}
        {% elsif settings.footer_layout == '03' %}
        {% section 'footer-3' %}
        {% elsif settings.footer_layout == '04' %}
        {% section 'footer-4' %}
        {% elsif settings.footer_layout == '05' %}
        {% section 'footer-5' %}
        {% endif %}

        {% unless template contains 'product' %}
        <div class="footbar-fixed">
            {% section 'someone-purchased' %}
            {% section 'GDPR-modal' %}
        </div>
        {% endunless %}
      {% if settings.enable_backtotop %}
        <div id="back-top" style="display: none;">
            <a class="nav_up" href="#top" title="Back to top">
                <i class="fa fa-angle-up" aria-hidden="true"></i>
            </a>
        </div>  
      {% endif %}
    </div>

    {% if settings.header_layout == 'vertical' %}
    </div>
    {% endif %}  
    
    {% render 'footer_scripts' %}
    
    {% render 'sweettooth-widgets' %}

    {% render 'search-autocomplete' %}
    
    {% if settings.header_layout == 'default' %}
    {% render 'customer_links' %}

    {% else %}
    <div class="translate-header" data-translate-header>
        {% render 'customer_links' %}
        {% render 'wrapper-top-cart' %}
    </div>
    {% endif %}

    {% render 'size-chart' %}
  
  	{% render 'size-chart-quickview' %}
        
    {% render 'message-modal' %}
    
    {% render 'newsletter' %}      
    
    {% if template contains 'product' %}
    {% render 'ask_an_expert' %}  
    {% endif %}
    {% render 'recently-viewed-products'%}
    <div class="wrapper-overlay"></div>
<script>
(function(g,e,o,t,a,r,ge,tl,y){
s=function(){var def='geotargetlygeocontent1595918464261_default',len=g.getElementsByClassName(def).length;
if(len>0){for(i=0;i<len;i++){g.getElementsByClassName(def)[i].style.display='inline';}}};
t=g.getElementsByTagName(e)[0];y=g.createElement(e);
y.async=true;y.src='https://g1584674684.co/gc?winurl='+encodeURIComponent(window.location)+'&refurl='+g.referrer+'&id=-MDJ8nGPSPqLOS7AbDlr';
t.parentNode.insertBefore(y,t);y.onerror=function(){s()};
})(document,'script');
</script>
<noscript><style>.geotargetlygeocontent1595918464261_default{display:inline !important}</style></noscript>
 
<script>
(function(g,e,o,t,a,r,ge,tl,y){
s=function(){var def='geotargetlygeocontent1595919149935_default',len=g.getElementsByClassName(def).length;
if(len>0){for(i=0;i<len;i++){g.getElementsByClassName(def)[i].style.display='inline';}}};
t=g.getElementsByTagName(e)[0];y=g.createElement(e);
y.async=true;y.src='https://g1584674684.co/gc?winurl='+encodeURIComponent(window.location)+'&refurl='+g.referrer+'&id=-MDJBPfCiFy7MnMQts7X';
t.parentNode.insertBefore(y,t);y.onerror=function(){s()};
})(document,'script');
</script>
<noscript><style>.geotargetlygeocontent1595919149935_default{display:inline !important}</style></noscript>
  
<script>
(function(g,e,o,t,a,r,ge,tl,y){
s=function(){var def='geotargetlygeocontent1639473626342_default',len=g.getElementsByClassName(def).length;
if(len>0){for(i=0;i<len;i++){g.getElementsByClassName(def)[i].style.display='inline';}}};
t=g.getElementsByTagName(e)[0];y=g.createElement(e);
y.async=true;y.src='https://g1584674684.co/gc?winurl='+encodeURIComponent(window.location)+'&refurl='+g.referrer+'&id=-MqsEYkni6AIuGSlbcfg';
t.parentNode.insertBefore(y,t);y.onerror=function(){s()};
})(document,'script');
</script>
<noscript><style>.geotargetlygeocontent1639473626342_default{display:inline !important}</style></noscript>
{%- render 'bold-currency-converter' -%}
{% if content_for_header contains 'product_label' %}{% include 'bss-product-label-js' %}{% include 'bss-label-style-css' %}{% include 'bss-product-label-fonts' %}{% endif %}

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ENjdO4Dr2bkBIFxQpeoTz1HIcje39Wm4jDKdf19U8gI4ddQ3GYNS7NTKfAdVQSZe" crossorigin="anonymous"></script><!--BS5 JS嵌入碼-->
  
  {% render 'gw-custom' %}

</body>
</html>

@Real_Power_JP
Hi, Do you wanted to add it right after the opening tag or before the closing tag?
You can check the screenshot.

1 Like

Thank you for your response! I will try if it works!