My site is now using Google tag manager for website analytics. It's very simply just a few lines of Google-provided javascript inserted just below the head tag of my layout page. What I'd like to do next is insert that snippet on the production server only. I don't want to make a DB call to do it either as some past community posts have discussed for actions based on server environment.
The reason behind "production only" is because my staging server is also on the same domain and Google tag manager doesn't make a distinction between hosts on a domain. Every time we access staging for testing, it's showing up as traffic in google analytics.
Does Wappler or Node offer a way to accomplish this? Sort of like Wappler's 'Condition' for App & Server Connect?
Thanks for the reply. What I've come across is a solution like the below code...
<% if (process.env.NODE_ENV === 'production') { %>
my GTM code here
<% } %>
However, there's still a Wappler bug where staging NODE_ENV results in 'production' and not 'staging'. Can I create a new global ENV variable and access it using process.env.MY_ENV ?