Checking for an Acquia Environment variable
The other question mentioned having passed that variable from a preprocess function to the template first. I guess that can be done using PHP's getenv then. Let me just try that out.

Yep, that works.

/**
 * Implements template_preprocess_page().
 */
function MYTHEME_preprocess_page(&amp;$variables) {
  $variables['my_environment'] = getenv('AH_SITE_ENVIRONMENT');
}


Then continue in page.tpl.php.

{% if my_environment == "prod" %}
  // Javascript Analytics Code
{% else %}
  &lt;!-- env is {{ my_environment }} --&gt;
{% endif %}