weblab-geniac-spaces commited on
Commit
40b51f1
1 Parent(s): 5a3d034

add analytics code

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -77,6 +77,18 @@ h3 {
77
  }
78
  """
79
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  tokenizer = AutoTokenizer.from_pretrained(MODEL)
81
  model = AutoModelForCausalLM.from_pretrained(
82
  MODEL,
@@ -135,7 +147,8 @@ def stream_chat(
135
 
136
  chatbot = gr.Chatbot(height=600, placeholder=PLACEHOLDER)
137
 
138
- with gr.Blocks(css=CSS, theme="soft") as demo:
 
139
  gr.HTML(TITLE)
140
  gr.DuplicateButton(value="Duplicate Space for private use", elem_classes="duplicate-button")
141
  gr.Markdown(DESCRIPTION)
 
77
  }
78
  """
79
 
80
+ ANALYTICS_HEAD = """
81
+ <script async src="https://www.googletagmanager.com/gtag/js?id=G-JLBL393020"></script>
82
+ """
83
+ ANALYTICS_JS = """
84
+ function() {
85
+ window.dataLayer = window.dataLayer || [];
86
+ function gtag(){dataLayer.push(arguments);}
87
+ gtag('js', new Date());
88
+ gtag('config', 'G-JLBL393020');
89
+ }
90
+ """
91
+
92
  tokenizer = AutoTokenizer.from_pretrained(MODEL)
93
  model = AutoModelForCausalLM.from_pretrained(
94
  MODEL,
 
147
 
148
  chatbot = gr.Chatbot(height=600, placeholder=PLACEHOLDER)
149
 
150
+ with gr.Blocks(head=ANALYTICS_HEAD, css=CSS, theme="soft") as demo:
151
+ demo.load(None, js=ANALYTICS_JS)
152
  gr.HTML(TITLE)
153
  gr.DuplicateButton(value="Duplicate Space for private use", elem_classes="duplicate-button")
154
  gr.Markdown(DESCRIPTION)