Skip to content

Commit

Permalink
detect clicks on flashcards and page view on flashcard page
Browse files Browse the repository at this point in the history
  • Loading branch information
saphal-upreti committed Jul 16, 2024
1 parent 0593e92 commit dd28888
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions nepalingo-web/src/components/Flashcard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@ import Card from "./Card";
import Button from "./Button";
import useDictionary from "../hooks/useDictionary";
import { generate } from "random-words";
import ReactGA from "react-ga4";

const Flashcard: React.FC = () => {
ReactGA.event({
category: "flash cards",
action: "Click",
value: 99, // optional, must be a number
nonInteraction: true, // optional, true/false
transport: "xhr", // optional, beacon/xhr/image
});
const [word, setWord] = useState("salt");
const [isFlipped, setIsFlipped] = useState(false);
const { data, isLoading, error } = useDictionary({
Expand Down
6 changes: 6 additions & 0 deletions nepalingo-web/src/pages/FlashcardPage.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import Flashcard from "../components/Flashcard";
import Header from "../components/header/Header";
import React from "react";
import ReactGA from "react-ga4";

const FlashcardPage: React.FC = () => {
ReactGA.send({
hitType: "pageview",
page: window.location.pathname,
title: "flashcard page",
});
return (
<>
<Header />
Expand Down

0 comments on commit dd28888

Please sign in to comment.