Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Website: Added More event triggers to website #2534

Merged
merged 3 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/website2/src/components/dialogs/EngagementDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useDispatch, useSelector } from '@/hooks';
import { postContactUs } from '@/services/externalService';
import { closeModal } from '@/store/slices/modalSlice';

import { trackEvent } from '../GoogleAnalytics';
import { CustomButton } from '../ui';

interface EngagementOption {
Expand Down Expand Up @@ -172,6 +173,17 @@ const EngagementDialog = () => {
const res = await postContactUs(requestBody);
if (res.success) {
setSubmissionSuccess(true);

// Fire the tracking event only on successful submission.
trackEvent({
action: 'submit_form',
category: 'engagement_dialog',
label: selectedCategory
? `engagement_dialog_submit_form_success_${selectedCategory}`
: 'engagement_dialog_submit_form_success',
});

// Reset form data after successful submission
setFormData({
firstName: '',
lastName: '',
Expand Down
18 changes: 16 additions & 2 deletions src/website2/src/components/layouts/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,27 @@ const Navbar: React.FC = () => {
</NavigationMenuItem>
))}
<CustomButton
onClick={() => dispatch(openModal())}
onClick={() => {
trackEvent({
action: 'button_click',
category: 'engagement',
label: 'get_involved',
});
dispatch(openModal());
}}
className="text-blue-600 bg-blue-50 transition rounded-none"
>
Get involved
</CustomButton>
<CustomButton
onClick={() => router.push('/explore-data')}
onClick={() => {
trackEvent({
action: 'button_click',
category: 'navigation',
label: 'explore_data',
});
router.push('/explore-data');
}}
className="rounded-none"
>
Explore data
Expand Down
7 changes: 7 additions & 0 deletions src/website2/src/components/layouts/NewsLetter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { CustomButton } from '@/components/ui';
import mainConfig from '@/configs/mainConfigs';
import { subscribeToNewsletter } from '@/services/externalService';

import { trackEvent } from '../GoogleAnalytics';

const NewsLetter: React.FC = () => {
const [formStatus, setFormStatus] = useState<'idle' | 'success' | 'error'>(
'idle',
Expand Down Expand Up @@ -32,6 +34,11 @@ const NewsLetter: React.FC = () => {
const response = await subscribeToNewsletter(formData);
if (response.success) {
setFormStatus('success');
trackEvent({
action: 'submit_form',
category: 'newsletter',
label: 'newsletter_subscription',
});
} else {
setFormStatus('error');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
import { FiChevronDown } from 'react-icons/fi';
import { IoLocationSharp } from 'react-icons/io5';

import { trackEvent } from '@/components/GoogleAnalytics';
import {
CustomButton,
Dialog,
Expand Down Expand Up @@ -224,7 +225,16 @@ const CountrySelectorDialog: React.FC = () => {
return (
<Dialog open={isOpen} onOpenChange={setIsOpen}>
<DialogTrigger asChild>
<button className="flex items-center space-x-2 px-4 py-2 bg-gray-100 rounded-xl text-gray-800 hover:bg-gray-200 transition-all">
<button
onClick={() => {
trackEvent({
action: 'button_click',
category: 'navigation',
label: 'country_selector',
});
}}
className="flex items-center space-x-2 px-4 py-2 bg-gray-100 rounded-xl text-gray-800 hover:bg-gray-200 transition-all"
>
<IoLocationSharp size={20} color="#2563eb" />
<span>
{selectedCountryData?.long_name.replace('_', ' ') ||
Expand Down
5 changes: 5 additions & 0 deletions src/website2/src/views/home/HomePlayerSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ const HomePlayerSection: React.FC = () => {
const modalPlayerRef = useRef<any>(null);

const handlePlayButtonClick = useCallback(() => {
trackEvent({
action: 'video_play',
category: 'video',
label: 'home_page_video',
});
setVideoState((prev) => ({ ...prev, isModalOpen: true }));
}, []);

Expand Down
Loading