Skip to content

Commit 1b6270c

Browse files
committed
Add Hotjar support
Summary: If configured, include the Hotjar script. Test Plan: - Set a HOTJAR_SITE_ID - Load a page in a production environment - Ensure the script is there Differential Revision: https://phabricator.opengovfoundation.org/D170
1 parent 3792c48 commit 1b6270c

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

config/services.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
'level' => env('ROLLBAR_LEVEL'),
2020
],
2121

22+
'hotjar' => [
23+
'site_id' => env('HOTJAR_SITE_ID'),
24+
],
25+
2226
'mailgun' => [
2327
'domain' => env('MAILGUN_DOMAIN'),
2428
'secret' => env('MAILGUN_SECRET'),

resources/views/layouts/app.blade.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
'csrfToken' => csrf_token(),
4444
]); ?>
4545
</script>
46+
47+
@if (App::environment('production', 'staging') && !empty(config('services.hotjar.site_id'))) {
48+
@include('partials/hotjar-script')
49+
@endif
4650
</head>
4751
<body>
4852
<div id="app" class="{{ isset($useDarkContentBg) ? 'dark-content' : '' }}">
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- Hotjar Tracking Code -->
2+
<script>
3+
(function(h,o,t,j,a,r){
4+
h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};
5+
h._hjSettings={hjid:{{ config('services.hotjar.site_id') }},hjsv:5};
6+
a=o.getElementsByTagName('head')[0];
7+
r=o.createElement('script');r.async=1;
8+
r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;
9+
a.appendChild(r);
10+
}) (window,document,'//static.hotjar.com/c/hotjar-','.js?sv=');
11+
</script>

0 commit comments

Comments
 (0)