score:0
this is the piece of code you should include:
(function(i,s,o,g,r,a,m){i['googleanalyticsobject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new date();a=s.createelement(o),
m=s.getelementsbytagname(o)[0];a.async=1;a.src=g;m.parentnode.insertbefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
or this if you want to keep your link to the analytics.js
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new date;
score:0
i suggest using the segment analytics library and following our react quickstart guide. you can track page visits with react-router and user behavior all within react components using 1 single api. here is an example of tracking a user signup
click using a react event handler:
export default class signupbutton extends component {
trackevent() {
window.analytics.track('user signup');
}
render() {
return (
<button onclick={this.trackevent}>
signup with segment today!
</button>
);
}
}
i’m the maintainer of https://github.com/segmentio/analytics-react. with segment, you’ll be able to switch different destinations on-and-off by the flip of a switch if you are interested in trying multiple analytics tools (we support over 250+ destinations) without having to write any additional code. 🙂
Source: stackoverflow.com
Related Query
- Display images in React using JSX without import
- Using React Router with CDN and without webpack or browserify
- How do I make components in React Native without using JSX?
- using mobx with react functional components and without decorators
- Get element reference without using refs in react
- React - Changing the state without using setState: Must avoid it?
- React component using jQuery without require - jest unit tests
- using React component library without @types
- React - How to access props without using constructor
- synchronise scroll of two react components without using state and actions
- How to import uikit js in react js without using the uikit component?
- How to redirect without flickering in React using React Router?
- can i use graphql in react without using Apollo?
- Invoke Lambda function from Amplify-generated React App without using API Gateway
- Using Require with React in a web page without node
- Is it possible to type a React function component with TypeScript without using arrow functions?
- How to add page transitions to React without using the router?
- How to change the Swiper height or slide width in React JS without using fixed CSS
- Using React without States
- React Native: How to switch page without using NavigatorIOS component?
- How to design my React project better without using shouldComponentUpdate
- Typescript and React refs without using inline lambdas
- Programmatically navigate using react router without duplicating paths
- How to handle props changes without using componentWillReceiveProps in React
- Is there a way to style an element in React using the ID without using className?
- React Router 1.0 using router.transitionTo() without Navigation mixin
- React remove object from list of objects without unique value, using hooks
- Conditional rendering of React components without using ternary operators
- Can lodash debounce be used in a state-less React component without using hooks?
- How to delete a list item in React Functional Component without using id
More Query from same tag
- Using globalCompositeOperation to mask Group of shapes, in React Konva
- How to close side panel on clicking anywhere in the document using react?
- React Mui-Dropzone Using multiple Dropzone on the same page
- On closing a particular tab it closes all the tabs
- React Data Grid: Custom DropDown Editor: value is not getting updated. Grid is not getting enabled for editing
- How to pass array to formdata and save as array in react.js
- Is setting value of the localStorage a side effect?
- its not uploading more than 2 files at same time in react filepond?
- How can I reach a nested element in an array (javascript)
- best practise with optional parts on html rendering
- React Ionic Tabs nested Routes Animación no works
- React Hooks / localStorage
- React 16.0.0 Parent Child GrandChild. Updating state in Parent does not update GrandChild
- Enzyme: How to test a wrapped form?
- Azure DevOps Update Variable Inside Code Before Deploy
- How to manage radio-buttons with checked value in react
- react-router 4 does not update url with query parameters
- Paint node panels on gojs
- React Hook useEffect has a missing dependency: 'dispatch'
- How to display arrays as Jsx elements in reactjs
- React Redirect in Fetch
- How to set marker icon in leaflet map?
- styling a caption to the center of a slider in react
- TypeError: Cannot destructure property 'products' of 'productList' as it is undefined
- How can I show the card I bought Antd side by side?
- How to transition from one page to another in react app
- How to pass parameters with a default value?
- How to prevent re-rendering the component which is inside router, when the state of super component changes?
- React Testing [Jest] problem - domain option is required
- Cannot read property 'date' of undefined React material design