Skip to content

Commit

Permalink
Add support for the self hosted Matomo tag manager
Browse files Browse the repository at this point in the history
  • Loading branch information
robdekort committed May 2, 2024
1 parent 8950bda commit 3e6456f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
20 changes: 20 additions & 0 deletions resources/fieldsets/globals_seo_trackers_analytics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,26 @@ fields:
- 'required_if:use_fathom,true'
if:
use_fathom: 'equals true'
-
handle: use_matomo
field:
type: toggle
instructions: 'Add the Matomo self hosted tag manager to your head.'
listable: false
display: Matomo
-
handle: matomo_script_url
field:
display: 'Script URL'
instructions: 'The Matomo tag manager script url including the container ID.'
input_type: text
type: text
listable: hidden
width: 50
validate:
- 'required_if:use_matomo,true'
if:
use_matomo: 'equals true'
-
handle: use_plausible
field:
Expand Down
4 changes: 4 additions & 0 deletions resources/views/snippets/_seo.antlers.html
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@
<script src="https://cdn.usefathom.com/script.js" site="{{ seo:fathom }}" defer></script>
{{ /if }}
{{ if seo:use_matomo }}
<script type="text/javascript">var _mtm = _mtm || []; _mtm.push({'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start'}); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.async=true; g.defer=true; g.src='{{ seo:matomo_script_url }}'; s.parentNode.insertBefore(g,s);</script>
{{ /if }}
{{ if seo:use_plausible && seo:plausible_use_custom_script }}
<script src="{{ seo:plausible_custom_script_url }}" data-domain="{{ seo:plausible }}" defer></script>
{{ elseif seo:use_plausible }}
Expand Down

0 comments on commit 3e6456f

Please sign in to comment.