commit 7aa2c1f904ed01dd0e4cc19985eb8d5664ff92d5 Shukry Zablah <shukryzablah@shukrys-mbp.lan> 2021-02-28 20:29:58 -0500 create gtag plugin, same as analytics, but updated
plugins/gtag.lisp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
diff --git a/plugins/gtag.lisp b/plugins/gtag.lisp new file mode 100644 index 0000000..06e59e1 --- /dev/null +++ b/plugins/gtag.lisp @@ -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)))