tgu-analytics
v1.0.15
Published
``` html <!-- 在HTML中插入以下代码,用于 ga 和 Matomo 埋点统计 --> <!-- Google Analytics --> <script> (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].
Downloads
12
Readme
埋点
<!-- 在HTML中插入以下代码,用于 ga 和 Matomo 埋点统计 -->
<!-- Google Analytics -->
<script>
(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');
if (window.location.hostname === 'g.togetu.in') {
ga('create', 'UA-127168940-2', 'auto');
} else {
ga('create', 'UA-127168940-3', 'auto');
}
</script>
<!-- End Google Analytics -->
<!-- Matomo -->
<script type="text/javascript">
window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function () {
var u = "https://togetu.matomo.cloud/";
_paq.push(['setTrackerUrl', u + 'piwik.php']);
_paq.push(['setSiteId', '1']);
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
g.type = 'text/javascript'; g.async = true; g.defer = true; g.src = u + 'piwik.js';s.parentNode.insertBefore(g, s);
})();
</script>
<!-- End Matomo Code -->
集成阿里云sls,ga, Matomo三种埋点 其中sls 和 Matomo 默认带参
this.params = {
currentPage: window.location.href,
UA: navigator.userAgent,
isToGetUApp: !!isToGetUApp,
H5_deviceId: H5_deviceId,
}
if(userInfo) {
this.params.uid = userInfo.tid
}
if(appInfo) {
this.params.app_deviceId = appInfo.deviceId;
this.params.app_version = appInfo.version;
this.params.app_version_name = appInfo.name;
}
if(bridge_userInfo_err) {
this.params = Object.assign(this.params, bridge_userInfo_err)
}
if(bridge_appInfo_err) {
this.params = Object.assign(this.params, bridge_appInfo_err)
}
使用方式
import push_log from 'tgu-analytics'
push_log({
category: 'H5_u28',
action: 'PV',
})
push_log({
category: 'H5_u28',
action: 'H5_u28_like_click',
nick: 'xiaoMing'
})