How to add conditional content to Nuxt.js app.html (app template)?

Viewed 1457

Anyone knows what templating language that Nuxt.js uses for their app.html?

I would like to add Google Analytics script only if there is GA ID defined on ENV

so it would be like this:

<!DOCTYPE html>
<html {{ HTML_ATTRS }}>
  <head {{ HEAD_ATTRS }}>
    ANOTHER META HERE
    <% if GOOGLE_ANALYTICS_IS_PRESENT_ON_ENV do %>
      <!-- Global site tag (gtag.js) - Google Analytics -->
      <script async src="https://www.googletagmanager.com/gtag/js?id=<%= process.env.NUXT_ENV_GOOGLE_ANALYTIC_ID %>">
      </script>
      <script>
        window.dataLayer = window.dataLayer || [];
        function gtag(){dataLayer.push(arguments);}
        gtag('js', new Date());

        gtag('config', '<%= process.env.NUXT_ENV_GOOGLE_ANALYTIC_ID %>');
      </script>
    <% endif %>
    {{ HEAD }}
  </head>
  <body {{ BODY_ATTRS }}>
    {{ APP }}
  </body>
</html>

please look at my if and endif tags above is it Shopify's Liquid template?

1 Answers
Related