useHead()
you can use this in your app.vue
file's script:
useHead({
script: [
{ src: "https://www.statcounter.com/counter/counter.js", body: true },
{
children:
"var sc_project=XXXXXXXX; var sc_invisible=1; var sc_security='XXXXXXXX'; ",
body: true,
},
],
noscript: [
{
children: "<div class='statcounter'><a title='Web Analytics Made Easy - Statcounter' href='https://statcounter.com/' target='_blank'><img class='statcounter' src='https://c.statcounter.com/XXXXXX/0/XXXXXX/1/' alt='Web Analytics Made Easy - Statcounter' referrerPolicy='no-referrer-when-downgrade'></a></div>",
body: true,
},
],
});
Learn more: https://nuxt.com/docs/getting-started/seo-meta#components
or
app config
use this in your nuxt.config.ts
file:
export default defineNuxtConfig({
app: {
head: {
htmlAttrs: { dir: "ltr", lang: "en" },
link: [{ rel: "icon", type: "image/x-icon", href: "/favicon.ico" }],
script: [
{ src: "https://www.statcounter.com/counter/counter.js", body: true },
{
children: "var sc_project=XXXXXXXX; var sc_invisible=1; var sc_security='XXXXXXXX'; ",
body: true,
},
],
noscript: [
{
children: "<div class='statcounter'><a title='Web Analytics Made Easy - Statcounter' href='https://statcounter.com/' target='_blank'><img class='statcounter' src='https://c.statcounter.com/XXXXXX/0/XXXXXX/1/' alt='Web Analytics Made Easy - Statcounter' referrerPolicy='no-referrer-when-downgrade'></a></div>",
body: true,
},
],
},
},
Learn more: https://nuxt.com/docs/api/configuration/nuxt-config#head
Components
use <NoScript>
and <Script>
components in your template:
<template>
<Script :body="true">
var sc_project=XXXXXXXX; var sc_invisible=1; var sc_security="XXXXXXXX";
</Script>
<Script
type="text/javascript"
src="https://www.statcounter.com/counter/counter.js"
:async="true"
></Script>
<NoScript :body="true">
<div class="statcounter">
<a
title="Web Analytics Made Easy - Statcounter"
href="https://statcounter.com/"
target="_blank"
><img
class="statcounter"
src="https://c.statcounter.com/XXXXXX/0/XXXXXX/1/"
alt="Web Analytics Made Easy - Statcounter"
referrerPolicy="no-referrer-when-downgrade"
/></a>
</div>
</NoScript>
</template>
Learn more: https://nuxt.com/docs/getting-started/seo-meta#body-tags
the result will be this :
