create gtag plugin, same as analytics, but updated
This commit is contained in:
parent
0b9f027a36
commit
7aa2c1f904
1 changed files with 21 additions and 0 deletions
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