react-ga

Adding Google Analytics to React

邮差的信 提交于 2020-06-09 08:14:28
问题 I am trying to add Google Analytics to a React Web Application. I know how to do it in HTML/CSS/JS sites and I have integrated it in an AngularJS app too. But, I'm not quite sure how to go about it when it comes to react. With HTML/CSS/JS, I had just added it to every single page. What I had done with AngularJS was adding GTM and GA script to index.html and added UA-labels to the HTML divs (and buttons) to get clicks. How can I do that with React? Please help! 回答1: Update: Feb 2019 As I saw

Adding Google Analytics to React

狂风中的少年 提交于 2020-06-09 08:13:44
问题 I am trying to add Google Analytics to a React Web Application. I know how to do it in HTML/CSS/JS sites and I have integrated it in an AngularJS app too. But, I'm not quite sure how to go about it when it comes to react. With HTML/CSS/JS, I had just added it to every single page. What I had done with AngularJS was adding GTM and GA script to index.html and added UA-labels to the HTML divs (and buttons) to get clicks. How can I do that with React? Please help! 回答1: Update: Feb 2019 As I saw

React-GA + Redux v7 incompatibility issue with jest

≡放荡痞女 提交于 2019-12-11 15:08:14
问题 I am using react-ga v2.5.7, for which I updated react-redux v7.0.2, and I am using jest v24.7.1 I set react-ga in testMode , and it is mocked in my jest.setup.js . But everytime I run my tests I am always encountering the same issue, most of the tests are failing for some weird reason: Test suite failed to run Cannot find module '@icons/material/CheckIcon' from 'SwatchesColor.js' However, Jest was able to find: './SwatchesColor.js' You might want to include a file extension in your import, or

How to use Google Analytics with React?

六眼飞鱼酱① 提交于 2019-12-05 05:42:46
问题 In my react app I have some pages: Main Service Contact Profile (private) etc.. I need to track users activity with Google Analytics. I googled react-ga and it's just fine. But with this library I have to initialize my GA on every route I use. For example: Route "/" - main page: class Main extends Component { componentDidMount() { initGA(); } render() { return ( <div> <Component1 /> <Component2 /> </div> ) } } My initGA() looks like: import ReactGA from 'react-ga'; export const initGA = () =>