Add third party script tags, JS SDK and tracking code without modifying any HTML code
npm install --save react-with-scripts
import React, { Component } from 'react';
import withScripts, { googleAnalytics } from 'react-with-scripts';
@withScripts(
googleAnalytics({
googleAnalyticsTrackingId: 'UA-XXXXX-XX',
}),
)
class App extends Component {
render() {
return (
<AppRoot>
{/* ... */}
</AppRoot>
)
}
}
or
import React from 'react';
import withScripts, { googleAnalytics } from 'react-with-scripts';
export const App = withScripts(
googleAnalytics({
googleAnalyticsTrackingId: 'UA-XXXXX-XX',
}),
)((props) => {
return (
<AppRoot>
{/* ... */}
</AppRoot>
)
});
googleAnalyticsTrackingId
googleOptimizeId
googleAnalyticsInit
(optional)- type - Function
- params -
ga
baiduTongjiId
baiduTongjiScript
(optional)
wechatScript
- type - String
wechatSignatureApi
- type - String
wechatDebug
- type - Boolean
wx.config({ debug: true,
wechatApiList
- type - Array
wx.config({ jsApiList: [],
growingIoAccountId
zhugeIoAppKey