Skip to content

Commit

Permalink
Track when subscribe form is submitted
Browse files Browse the repository at this point in the history
  • Loading branch information
kudlajz committed Apr 5, 2024
1 parent 7bb5bf0 commit 69e46e1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions modules/Layout/SubscribeForm/SubscribeForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import HCaptcha from '@hcaptcha/react-hcaptcha';
import { ACTIONS, useAnalytics } from '@prezly/analytics-nextjs';
import { getPrivacyPortalUrl } from '@prezly/theme-kit-core';
import { translations } from '@prezly/theme-kit-intl';
import { useCurrentLocale, useNewsroom } from '@prezly/theme-kit-nextjs';
Expand All @@ -18,6 +19,7 @@ const NEXT_PUBLIC_HCAPTCHA_SITEKEY = process.env.NEXT_PUBLIC_HCAPTCHA_SITEKEY;
function SubscribeForm() {
const newsroom = useNewsroom();
const currentLocale = useCurrentLocale();
const { track } = useAnalytics();
const { formatMessage } = useIntl();

const captchaRef = useRef<HCaptcha>(null);
Expand Down Expand Up @@ -55,6 +57,7 @@ function SubscribeForm() {
return;
}

track(ACTIONS.SUBSCRIBE_FORM_SUBMIT);
window.location.href = getPrivacyPortalUrl(newsroom, currentLocale, { email });
} catch (error) {
if (error instanceof Error) {
Expand Down

0 comments on commit 69e46e1

Please sign in to comment.