Skip to content

Commit

Permalink
Add Hotjar.com integration
Browse files Browse the repository at this point in the history
Resolves #148
  • Loading branch information
zapotocnylubos committed Aug 25, 2024
1 parent 2cfee29 commit 55647de
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions etc/db-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,11 @@
default_value: ""
public: false
description: The tracking ID for Google Analytics.
- name: hotjar_tracking_id
type: string
default_value: ""
public: false
description: The tracking ID for Hotjar.
- name: discord_invite_url
type: string
default_value: ""
Expand Down
3 changes: 3 additions & 0 deletions webapp/src/Twig/TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ public function getGlobals(): array
'google_analytics_tracking_id' =>
$this->tokenStorage->getToken() && $this->authorizationChecker->isGranted('ROLE_ADMIN') ?
'' : $this->config->get('google_analytics_tracking_id'),
'hotjar_tracking_id' =>
$this->tokenStorage->getToken() && $this->authorizationChecker->isGranted('ROLE_ADMIN') ?
'' : $this->config->get('hotjar_tracking_id'),
'discord_invite_url' => $this->config->get('discord_invite_url'),
];
}
Expand Down
14 changes: 14 additions & 0 deletions webapp/templates/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@
gtag('config', '{{ google_analytics_tracking_id }}');
</script>
{% endif %}

{% if hotjar_tracking_id is not empty %}
<!-- Hotjar Tracking -->
<script>
(function(h,o,t,j,a,r){
h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};
h._hjSettings={hjid:{{ hotjar_tracking_id }},hjsv:6};
a=o.getElementsByTagName('head')[0];
r=o.createElement('script');r.async=1;
r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;
a.appendChild(r);
})(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');
</script>
{% endif %}
</head>
<body{% if static is defined and static %} class="static"{% endif%}>
{% block menu %}{% endblock %}
Expand Down

0 comments on commit 55647de

Please sign in to comment.