Trouble with Analytics


#1

First of all, sorry if the Topic is wrong.

Hey guys, I’m having trouble with Analytics.

I made my site using Yesod and for traffic purposes, I’m trying to put Analytics. I spoke with some people and they said to just put in Julius (in Stack they said to put in a JS file)

toWidgetHead [julius|
        <!-- Global site tag (gtag.js) - Google Analytics -->
        <script async src="https://www.googletagmanager.com/gtag/js?id=UA-MYUA"></script>
            <script>
            window.dataLayer = window.dataLayer || [];
            function gtag(){dataLayer.push(arguments);}
             gtag('js', new Date());

            gtag('config', 'UA-MYUA');
        |]

But Google don’t recognize it and my console shows me this:

SyntaxError: expected expression, got ‘<’

Google don’t recognize it too. So I want to know, does Haskell has his own Analytics code ?

The site is incomplete, but if you want to know the URL just ask me.

Thanks for the help.


#2

I think the problem is that the TemplateHaskell and QuasiQuotes language extensions are not enabled. You can enable them by putting this at the top of the file:

{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE QuasiQuotes #-}

Edit: Wait did you write in a JS file? That is strange. The way you wrote the julius code with the [julius| ... |] notation is called a QuasiQuote and that should go in a Haskell file.