Add google analytics tracking code to Dash App

I am trying to add Google Analytics tracking to a Dash Web Application. I reviewed other similar questions and followed the suggestion, however, I am running into an issue.

In my app.py,

app = dash.Dash(....) 

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

            gtag('config', 'G-XXXXXXXX');
        </script>
    </head>
</html>

Error:

<html>
    ^
SyntaxError: invalid syntax

How can I add GA tracking code in my Dash App?



Read more here: https://stackoverflow.com/questions/66267589/add-google-analytics-tracking-code-to-dash-app

Content Attribution

This content was originally published by kms at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: