Skip to content

Commit

Permalink
Adding some homegrown analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
Duncanma committed May 25, 2024
1 parent f8a7e61 commit fe7ffbe
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ disableHugoGeneratorInject = false
# Default theme "light" or "dark"
defaultTheme = "dark"
themeColor = "#252627"
homegrownAnalytics = "https://functions.duncanmackenzie.net/api/event?code=Z2iNU1ncqSCA9CMwMSVhgQfcQAOuqwtyDkpKKfeqqB0oAzFudj2C3g%3D%3D"


[params.logo]
Expand Down
9 changes: 9 additions & 0 deletions themes/hello-friend-ng/assets/scss/galleries/_styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,19 @@ section.featured .card {
}
}


body.showBuyButtons .gallery-item span.clickToBuy {
display: inline;
}

body.noJS .gallery-item span.clickToBuy {
display: none;
}

body.noJS div.availableForPurchase {
display: none;
}

div.availableForPurchase {
font-size: small;
font-style: italic;
Expand Down
17 changes: 17 additions & 0 deletions themes/hello-friend-ng/layouts/partials/homegrown-analytics.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- $rootPath := .Site.Params.homegrownAnalytics }}
<noscript>
<img src="{{ $rootPath }}&page={{ .RelPermalink }}&title={{ .Title }}" height="1" width="1">
</noscript>
<div id="analytics">
</div>
<script>
var referrer = document.referrer;
var img = document.createElement("img");
img.src = "{{ $rootPath }}&page={{ .RelPermalink }}&title={{ .Title }}&js_enabled";
img.height = "1";
img.width = "1";
if (referrer) {
img.src += "&referrer=" + encodeURIComponent(referrer);
}
document.getElementById('analytics').appendChild(img);
</script>
4 changes: 4 additions & 0 deletions themes/hello-friend-ng/layouts/partials/javascript.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
<script src="{{ $val }}"></script>
{{ end }}
{{ end }}
{{- if .Site.Params.homegrownAnalytics -}}
{{- partial "homegrown-analytics.html" . }}
{{- end }}

{{- if .Site.GoogleAnalytics }}
<!-- Google Analytics -->
<script>
Expand Down

0 comments on commit fe7ffbe

Please sign in to comment.