Dodaj Google Analytics, aby zareagować
Bash/CMD: yarn add react-ga
//useAnalyticsEventTracker.jsx
import React from "react";
import ReactGA from "react-ga";
const AnalyticsEventTracker = (category="Blog category") => {
const eventTracker = (action = "test action", label = "test label") => {
ReactGA.event({category, action, label});
}
return eventTracker;
}
export default AnalyticsEventTracker;
//ContactUs.jsx
import AnalyticsEventTracker from './AnalyticsEventTracker';
const ContactUs = () => {
const gaEventTracker = AnalyticsEventTracker('Contact us');
return(
<div>
<h3>Contact Us</h3>
<div>
<a href="#" onClick={()=>gaEventTracker('call')}>Call Us</a>
</div>
<div>
<a href="mailto:[email protected]" onClick={()=>gaEventTracker('email')}>Write to us</a>
</div>
</div>)
};
capitalistlion