Skip to content

Commit

Permalink
repman
Browse files Browse the repository at this point in the history
  • Loading branch information
mical committed Feb 20, 2023
1 parent f25582a commit 069ce08
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ OAUTH_BUDDY_CLIENT_SECRET=

###> google analytics ###
GA_TRACKING=
GA4_TRACKING=
###< google analytics ###

###> storage ###
Expand Down
1 change: 1 addition & 0 deletions .env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ OAUTH_BUDDY_CLIENT_SECRET=

###> google analytics ###
GA_TRACKING=
GA4_TRACKING=
###< google analytics ###

###> storage ###
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/app.deploy/templates/.env.local
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ OAUTH_BUDDY_CLIENT_SECRET={{ lookup('env', 'REPMAN_OAUTH_BUDDY_CLIENT_SECRET') o
TRUSTED_PROXIES={{ lookup('env', 'REPMAN_TRUSTED_PROXIES') or '' }}

GA_TRACKING={{ lookup('env', 'REPMAN_GA_TRACKING') or '' }}
GA4_TRACKING={{ lookup('env', 'REPMAN_GA4_TRACKING') or '' }}

EWZ_RECAPTCHA_ENABLED={{ lookup('env', 'REPMAN_EWZ_RECAPTCHA_ENABLED') or 'false' }}
EWZ_RECAPTCHA_SITE_KEY={{ lookup('env', 'REPMAN_EWZ_RECAPTCHA_SITE_KEY') or 'empty' }}
Expand Down
1 change: 1 addition & 0 deletions config/packages/twig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ twig:
'%kernel.project_dir%/public': public
globals:
ga_tracking: '%env(resolve:GA_TRACKING)%'
ga4_tracking: '%env(resolve:GA4_TRACKING)%'
config: '@Buddy\Repman\Service\Config'
5 changes: 5 additions & 0 deletions templates/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@
<script>{% include 'component/js/ga.js' %}</script>
{% endif %}

{% if ga4_tracking is not empty %}
<script async src="https://www.googletagmanager.com/gtag/js?id={{ ga4_tracking }}"></script>
<script>{% include 'component/js/ga4.js' %}</script>
{% endif %}

<script>{% include 'component/js/base.js' %}</script>
{% block javascripts %}{% endblock %}
</body>
Expand Down
7 changes: 7 additions & 0 deletions templates/component/js/ga4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(function() {
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '{{ ga4_tracking }}');
})();

0 comments on commit 069ce08

Please sign in to comment.