我使用的是Matomo的Vue插件,可以在这里找到:https://github.com/AmazingDreams/vue-matomo
我在我的main.js入口文件中导入了VueMatomo插件,如下所示:
import VueMatomo from 'vue-matomo';
然后,我在main.js文件中将VueMatomo指定为全局方法,如下所示:
Vue.use(VueMatomo, {
// Configure your matomo server and site
host: 'https://matomo.example.com',
siteId: 1,
// Enables link tracking on regular links. Note that this won't
// work for routing links (ie. internal Vue router links)
// Default: true
enableLinkTracking: true,
// Require consent before sending tracking information to matomo
// Default: false
requireConsent: false,
// Whether to track the initial page view
// Default: true
trackInitialView: true,
// Changes the default .js and .php endpoint's filename
// Default: 'piwik'
trackerFileName: 'piwik',
// Whether or not to log debug information
// Default: false
debug: false
});
如何在这个插件中实现标签?我是否可以像这样将trackerUrl设置为容器url:
// Overrides the autogenerated tracker endpoint entirely
// Default: undefined
trackerUrl: 'https://mycontainer.js'
另外,我如何发送自定义数据。例如:
'user':{
'role':'consumer',
'type':'purchaser'
}
编辑:在Matomo标签管理器文档中,它说要将这个放在head标签中。
<!-- MTM -->
<script type="text/javascript">
var _mtm = _mtm || [];
_mtm.push({'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start'});
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src='https://mycontainer.js'; s.parentNode.insertBefore(g,s);
</script>
<!-- End MTM -->
那么vue-matomo插件是否仍然需要这样做,或者您是否可以将
g.src='https://mycontainer.js'
其他地方?
发布于 2019-05-01 00:50:21
在幕后,Vue Plugin
简单地向您公开了Matomo tracking client SDK
。您可以通过this.$matomo
调用任何原生SDK函数listed in their SDK on their website。
实际上,你可以在源代码中看到他们这样做:
const Matomo = MatomoJS.getTracker(trackerEndpoint, siteId)
// Assign matomo to Vue
Vue.prototype.$piwik = Matomo
Vue.prototype.$matomo = Matomo
其中MatomoJS
是通过import Matomojs from './matomo'
解析的,它只是一个打包了他们的public SDK的flat javascript file
。
https://stackoverflow.com/questions/55925235
复制相似问题