Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
use GA tag from site config (#25)
Browse files Browse the repository at this point in the history
Addresses #14 

This fetches a Google Analytics tag from a config file in aep.dev

aep-dev/aeps#154 should be merged along with
this change.
  • Loading branch information
rambleraptor authored Apr 10, 2024
1 parent 42bcc70 commit 5df9a8e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions aep_site/support/templates/layouts/base.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,24 @@
{% block js -%}
{% endblock -%}
{# {% seo %} -- port this #}
{% if site.config.site.ga_tag %}
<!-- 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-NSXMVSDN');</script>
})(window,document,'script','dataLayer','{{ site.config.site.ga_tag }}');</script>
<!-- End Google Tag Manager -->
{% endif %}
</head>
<body>

{% if site.config.site.ga_tag %}
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-NSXMVSDN"
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id={{ site.config.site.ga_tag }}"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
{% endif %}
{% include 'includes/header.html.j2' %}
<div class="glue-page">
{% block main %}
Expand Down
1 change: 1 addition & 0 deletions tests/test_data/config/site.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ga_tag: testtag

0 comments on commit 5df9a8e

Please sign in to comment.