2016-11-10 91 views
0

我目前的分析設置是這樣的:如何使用React Router爲Google Analytics添加自定義維度?

this.context.router.listen(location => { 
    analytics.page(location.pathname, { 
    title: document.title, 
    url: `${config.HOST_URL}${this.context.router.createHref(location)}`, 
    path: this.context.router.createHref(location), 
    referrer: document.referrer, 
    state: location.state, 
    }); 
}); 

location對象數據的量是相當小。問題是,如何獲取有關在componentDidMount塊中加載的項目的信息進入頁面跟蹤?

在此特定實例中,我試圖將用戶正在查看的作品的信息添加到Google分析中作爲自定義維度。下面的鏈接顯示了它通常如何添加。

https://support.google.com/analytics/answer/2709828?hl=en#example-hit

我使用的反應路由器V2

回答

0

從給出的信息,我會說你最好的選擇是要添加更多的數據放在一個條件在聽者的頁面不記錄是否加載該頁面。然後在您有數據的componentDidMount中調用頁面的分析。

基本上只是爲那些需要更多數據的頁面覆蓋它。

相關問題