Skip to content

Commit 689f32d

Browse files
committed
Add GA tracking
1 parent 2d6f8e6 commit 689f32d

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/components/PromoBanner.jsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
11
// components/PromoBanner.tsx
22
import React from "react";
3+
import ReactGA from "react-ga4";
34

45
export const PromoBanner = () => {
5-
const now = new Date();
6-
const endDate = new Date("2025-05-06"); // End of May 5
7-
8-
if (now > endDate) return null;
6+
const handleFreeEbookClick = (event) => {
7+
event.preventDefault();
8+
const href = event.currentTarget.href;
9+
10+
// Track event with Google Analytics
11+
ReactGA.event({
12+
category: "Promo Banner",
13+
action: "click",
14+
label: "Free eBook Download",
15+
});
16+
17+
// Redirect after slight delay to ensure tracking fires
18+
setTimeout(() => {
19+
window.location.href = href;
20+
}, 150);
21+
};
922

1023
return (
1124
<div className="bg-blue-100 text-blue-900 text-center py-3 px-4 shadow-md mt-14 md:mt-16">
1225
📚 <strong>Free eBook!</strong> Download <em>“Challenges at Azelica”</em> for free from <strong>May 1-5, 2025</strong>. First in the <em>Bine Ari Digit</em> series! 👉{" "}
1326
<a
1427
href="https://www.amazon.com/Challenges-Azelica-BAD-Adventures-Fable-ebook/dp/B0CP2QHQYC"
28+
onClick={handleFreeEbookClick}
1529
className="underline text-blue-800 font-semibold hover:text-blue-600"
1630
>
1731
Download Now

0 commit comments

Comments
 (0)