create gtag plugin, same as analytics, but updated

This commit is contained in:
Shukry Zablah 2021-02-28 20:29:58 -05:00
parent 0b9f027a36
commit 7aa2c1f904

21
plugins/gtag.lisp Normal file
View 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)))