import React, { useEffect } from "react";
import { useLocation } from "react-router-dom";

const useAnalytics = () => {
    const location = useLocation();

    useEffect(() => {
        window.gtag('event', 'page_view', {
            page_title: document.title,
            page_path: location.pathname + location.search,
            page_location: window.location.href
        })
    }, [location]);
}

export default useAnalytics;
