Next.js Discord

Discord Forum

sendGAevent

Unanswered
Tripp posted this in #help-forum
Open in Discord
https://nextjs.org/docs/app/building-your-application/optimizing/third-party-libraries#google-analytics

Anyone else tried unsing this. My page is tracking page_views, scroll, etc. But sendGAevent is not working.
"use client";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { FC } from "react";
import { sendGAEvent } from "@next/third-parties/google";

export const BookLink: FC<{
className: string;
href: string;
children: React.ReactNode;
}> = ({ className, href, children }) => {
const path = usePathname();
return (
<Link href={href} className={className}>
<button
onClick={() => {
sendGAEvent("forwarded_to_booking", "click", { path });
}}
>
{children}
</button>
</Link>
);
};

1 Reply