Track key events

This commit is contained in:
Ben Grant 2021-04-12 13:27:23 +10:00
parent 1b40a5919b
commit 003f4e811a
3 changed files with 11 additions and 2 deletions

View file

@ -2,7 +2,7 @@ import { Button } from 'components';
const Donate = () => ( const Donate = () => (
<div style={{ marginTop: 6, marginLeft: 12 }}> <div style={{ marginTop: 6, marginLeft: 12 }}>
<a href="https://www.paypal.com/donate?business=N89X6YXRT5HKW&item_name=Crab+Fit+Donation&currency_code=AUD" target="_blank" rel="noreferrer"> <a onClick={() => gtag('event', 'donate', { 'event_category': 'donate' })} href="https://www.paypal.com/donate?business=N89X6YXRT5HKW&item_name=Crab+Fit+Donation&currency_code=AUD" target="_blank" rel="noreferrer">
<Button <Button
buttonHeight="30px" buttonHeight="30px"
buttonWidth="90px" buttonWidth="90px"

View file

@ -257,6 +257,9 @@ const Event = (props) => {
} }
} finally { } finally {
setIsLoginLoading(false); setIsLoginLoading(false);
gtag('event', 'login', {
'event_category': 'event',
});
} }
}; };
@ -279,6 +282,9 @@ const Event = (props) => {
.then(() => { .then(() => {
setCopied('Copied!'); setCopied('Copied!');
setTimeout(() => setCopied(null), 1000); setTimeout(() => setCopied(null), 1000);
gtag('event', 'copy_link', {
'event_category': 'event',
});
}) })
.catch((e) => console.error('Failed to copy', e)) .catch((e) => console.error('Failed to copy', e))
} }
@ -286,7 +292,7 @@ const Event = (props) => {
>{copied ?? `https://crab.fit/${id}`}</ShareInfo> >{copied ?? `https://crab.fit/${id}`}</ShareInfo>
<ShareInfo isLoading={isLoading}> <ShareInfo isLoading={isLoading}>
{!!event?.name && {!!event?.name &&
<>Copy the link to this page, or share via <a href={`mailto:?subject=${encodeURIComponent(`Scheduling ${event?.name}`)}&body=${encodeURIComponent(`Visit this link to enter your availabilities: https://crab.fit/${id}`)}`}>email</a>.</> <>Copy the link to this page, or share via <a onClick={() => gtag('event', 'send_email', { 'event_category': 'event' })} href={`mailto:?subject=${encodeURIComponent(`Scheduling ${event?.name}`)}&body=${encodeURIComponent(`Visit this link to enter your availabilities: https://crab.fit/${id}`)}`}>email</a>.</>
} }
</ShareInfo> </ShareInfo>
</> </>

View file

@ -131,6 +131,9 @@ const Home = () => {
}, },
}); });
push(`/${response.data.id}`); push(`/${response.data.id}`);
gtag('event', 'create_event', {
'event_category': 'home',
});
} catch (e) { } catch (e) {
setError('An error ocurred while creating the event. Please try again later.'); setError('An error ocurred while creating the event. Please try again later.');
console.error(e); console.error(e);