Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

marketing: Track which marketing buttons get clicked.

Shubham Padiac2895b90ea89
diff --git a/templates/corporate/slack-alternative.html b/templates/corporate/slack-alternative.html
index df2a1d79c9e..3c9510d7cf3 100644
--- a/templates/corporate/slack-alternative.html
+++ b/templates/corporate/slack-alternative.html
@@ -19,10 +19,10 @@
<p>Organized team chat that makes your team more productive.</p>
</div>
<div class="hero-buttons center">
- <a href="/" class="button">
+ <a href="/" class="button analytics-click" data-button-id="slack-alternative-hero-get-started">
{{ _('Get started') }}
</a>
- <a href="#compare" class="button">
+ <a href="#compare" class="button analytics-click" data-button-id="slack-alternative-hero-see-comparison">
{{ _('See the comparison') }}
</a>
</div>
@@ -334,7 +334,7 @@
</tbody>
</table>
<div class="compare-cta center register-buttons">
- <a href="/" class="button">
+ <a href="/" class="button analytics-click" data-button-id="slack-alternative-compare-get-started">
{{ _('Get started') }}
</a>
</div>
@@ -374,7 +374,7 @@
<div class="why-zulip">
<div class="discounts-section">
<div class="register-buttons">
- <a href="/" class="register-now button">{{ _('Get started') }}</a>
+ <a href="/" class="register-now button analytics-click" data-button-id="slack-alternative-bottom-get-started">{{ _('Get started') }}</a>
</div>
</div>
</div>
diff --git a/web/src/portico/google-analytics.ts b/web/src/portico/google-analytics.ts
index 0e7ac17cd8f..f4a351a7d0c 100644
--- a/web/src/portico/google-analytics.ts
+++ b/web/src/portico/google-analytics.ts
@@ -1,5 +1,6 @@
import {gtag, install} from "ga-gtag";
import type {ConfigParams} from "ga-gtag";
+import {$} from "jquery";
import {page_params} from "../base_page_params.ts";
@@ -10,6 +11,13 @@ if (page_params.google_analytics_id !== undefined) {
config = (info) => {
gtag("config", page_params.google_analytics_id!, info);
};
+
+ // Google Analytics doesn't record clicks on links within our site,
+ // so we send our own event to tell apart links like several
+ // "Get started" buttons that all go to /.
+ $(document).on("click", ".analytics-click", function () {
+ gtag("event", "marketing_click", {button_id: $(this).attr("data-button-id")!});
+ });
} else {
config = () => {
// No Google Analytics tracking configured.