Translation Word Tag Stats - warwickfoster/qurantools GitHub Wiki

Purpose

The PHP code snippet you provided is used to conditionally include Google Tag Manager (GTM) code in a web page based on the user's login status.

How it Works

  • The code checks if the is_show_google_tag_manager() function returns true.
  • If the function returns true, the GTM code is included in the HTML output.
  • The is_show_google_tag_manager() function is not provided in the code snippet, so it is assumed to be defined elsewhere.
  • The $config['google_tag_manager_code'] variable is used to retrieve the GTM container ID from a configuration variable.

Output

If the user is logged in, the following HTML code will be included in the page:

<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','[GTM container ID]');</script>
<!-- End Google Tag Manager -->

Conclusion

The code snippet allows website owners to track user interactions and analyze website traffic more effectively by incorporating GTM into their pages.

⚠️ **GitHub.com Fallback** ⚠️