Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google analytics integration #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Hugo UILite portfolio theme is designed especially for designers and developers
- Contact Form
- Social links
- Good SEO
- Google Analytics Integration

### Pro version also includes

Expand All @@ -29,4 +30,4 @@ Hugo UILite portfolio theme is designed especially for designers and developers

- [Register](https://formspree.io/)
- [Create a Project and a Form](https://help.formspree.io/hc/en-us/articles/360053239754-Getting-started-with-projects)
- Add your **form endpoint** to `data/config.json`
- Add your **form endpoint** to `data/config.json`
9 changes: 9 additions & 0 deletions layouts/partials/google-analytics.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ .Site.Params.gaMeasurementID }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '{{ .Site.Params.gaMeasurementID }}');
</script>
12 changes: 12 additions & 0 deletions layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
{{ if .Site.Params.gaMeasurementID }}
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ .Site.Params.gaMeasurementID }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '{{ .Site.Params.gaMeasurementID }}');
</script>
{{ end }}

<title>
{{ $url := replace .Permalink ( printf "%s" .Site.BaseURL) "" }}
{{ if .IsHome }}
Expand Down