Skip to content

Commit

Permalink
Merge pull request #894 from prezly/feature/dev-12745-add-subscribe-f…
Browse files Browse the repository at this point in the history
…orm-submit-event

[DEV-12745] Track when subscribe form is submitted
  • Loading branch information
kudlajz authored Apr 5, 2024
2 parents 3e4f9b9 + 69e46e1 commit 49c1cd7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 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
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@hcaptcha/react-hcaptcha": "1.9.3",
"@headlessui/react": "1.7.18",
"@playwright/test": "^1.33.0",
"@prezly/analytics-nextjs": "2.0.0",
"@prezly/analytics-nextjs": "2.0.1",
"@prezly/content-renderer-react-js": "0.35.0",
"@prezly/sdk": "18.3.0",
"@prezly/story-content-format": "0.64.0",
Expand Down

0 comments on commit 49c1cd7

Please sign in to comment.