Skip to content

how to use import.meta.env.[key] in index.html #3681

Answered by jclaveau
yangmi0829 asked this question in Q&A
Discussion options

You must be logged in to vote

In my case it works perfectly:

  <script>
    (function (w, d, s, l, i) {
      var f  = d.getElementsByTagName(s)[0],
          j  = d.createElement(s),
          dl = l != 'dataLayer' ? '&l=' + l : '';
      j.async = true;
      j.src = '/gtm.js?id=' + i + dl + '&%VITE_GTM_URL_OPTIONS%';
      f.parentNode.insertBefore(j, f);
    })(window, document, 'script', 'dataLayer', 'GTM-XXXXX');
  </script>

Did you follow the docs?

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@bliu13
Comment options

@jclaveau
Comment options

Answer selected by sapphi-red
@bliu13
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants