Merge pull request #197 from shukryzablah/update-analytics-plugin
Update google analytics integration: create gtag plugin
This commit is contained in:
commit
891bfd52de
2 changed files with 24 additions and 1 deletions
|
@ -19,7 +19,9 @@ The former default deployment method.
|
|||
**Description**: Provides traffic analysis through
|
||||
[Google Analytics](http://www.google.com/analytics/).
|
||||
|
||||
**Example**: `(analytics :tracking-code "google-provided-unique-id")`
|
||||
**Example**: `(gtag :tracking-code "google-provided-unique-id")`
|
||||
|
||||
**Note**: You can use `(analytics :tracking-code "google-provided-unique-id")` for the legacy integration with Google Analytics.
|
||||
|
||||
## Analytics via Piwik
|
||||
|
||||
|
|
21
plugins/gtag.lisp
Normal file
21
plugins/gtag.lisp
Normal file
|
@ -0,0 +1,21 @@
|
|||
(defpackage :coleslaw-gtag
|
||||
(:use :cl)
|
||||
(:export #:enable)
|
||||
(:import-from :coleslaw #:add-injection))
|
||||
|
||||
(in-package :coleslaw-gtag)
|
||||
|
||||
(defvar *analytics-js*
|
||||
"<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async src='https://www.googletagmanager.com/gtag/js?id=~a'></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', '~a');
|
||||
</script>")
|
||||
|
||||
(defun enable (&key tracking-code)
|
||||
(let ((snippet (format nil *analytics-js* tracking-code tracking-code)))
|
||||
(add-injection (constantly snippet) :head)))
|
Loading…
Add table
Reference in a new issue