Skip to content

Commit

Permalink
feat: add Matomo analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
heeckhau committed Jul 22, 2024
1 parent d945f89 commit c30f722
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
14 changes: 13 additions & 1 deletion theme/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -338,5 +338,17 @@
{{/if}}

</div>
</body>
<script>
var _paq = window._paq = window._paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://psedev.matomo.cloud/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '16']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src='//cdn.matomo.cloud/psedev.matomo.cloud/matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
</body>
</html>
19 changes: 18 additions & 1 deletion theme/update_theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,25 @@ fn main() -> io::Result<()> {
.collect::<Vec<_>>()
.join("\n");

// Add Matomo tracking script before </body>
let tracking_script = r#" <script>
var _paq = window._paq = window._paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://psedev.matomo.cloud/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '16']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src='//cdn.matomo.cloud/psedev.matomo.cloud/matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
</body>"#;

let final_content = filtered_content.replace("</body>", tracking_script);

let mut file = File::create("index.hbs")?;
file.write_all(filtered_content.as_bytes())?;
file.write_all(final_content.as_bytes())?;

Ok(())
}

0 comments on commit c30f722

Please sign in to comment.