How to set up Google Analytics for React-Router?

后端 未结 15 655
名媛妹妹
名媛妹妹 2020-12-12 12:25

I\'m trying set up Google Analytics on my react site, and have come across a few packages, but none of which has the kind of set up that I have in terms of examples. Was ho

15条回答
  •  庸人自扰
    2020-12-12 13:25

    I would suggest using the excellent react-router-ga package that is extremely lightweight and easy to configure, especially when using the BrowserRouter wrapper.

    Import the component:

    import Analytics from 'react-router-ga';

    Then simply add the within your BrowserRouter:

    
        
            
                
            
        
    
    

提交回复
热议问题