V
V
Valeriu Vodnicear2019-12-11 18:46:24
JavaScript
Valeriu Vodnicear, 2019-12-11 18:46:24

How to add code from Naver Analytics to a site with Nuxt.js?

How to add tracking code from Naver Analytics to Nuxt.js website?
Tracking code example:

<script type="text/javascript" src="//wcs.naver.net/wcslog.js"></script>
<script type="text/javascript">
if(!wcs_add) var wcs_add = {};
wcs_add["wa"] = "123456789";
wcs_do();
</script>

tried like this:
nuxt.config.js:
script: [
      { src: '//wcs.naver.net/wcslog.js' }
    ]

...
{src: '~plugins/naver-analytics.js', ssr: false}
...
plugins/naver-analytics.js
export default ({ app }) => {
  if(!wcs_add) var wcs_add = {};
  wcs_add["wa"] = "123";
  wcs_do();
  wcs.event('create', '123', 'auto')
  app.router.afterEach((to, from) => {
    wcs.event('set', 'page', to.fullPath)
    wcs.event('send', 'pageview')
  })
}

but of course nothing works.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question