vite-plugin-radar
Analytics loader for vite that support Google Analytics, Google Tag Manager, Facebook Pixel,
Linkedin Insight, Yandex Metrica, Baidu Tongji, Microsoft Advertising and Unbounce
Install
npm i --save-dev vite-plugin-radar
Add it to vite.config.js
import { VitePluginRadar } from 'vite-plugin-radar'
export default {
plugins: [
VitePluginRadar({
analytics: {
id: 'G-XXXXX',
},
})
],
}
Options
import { VitePluginRadar } from 'vite-plugin-radar'
export default {
plugins: [
VitePluginRadar({
enableDev: true,
analytics: [
{
id: 'G-XXXXX',
disable: true,
config: {
cookie_domain: 'auto',
cookie_expires: 63072000,
cookie_prefix: 'none',
cookie_update: true,
cookie_flags: '',
send_page_view: true,
allow_google_signals: true,
allow_ad_personalization_signals: true,
},
consentDefaults: {
analytics_storage: 'granted',
ad_storage: 'denied',
wait_for_update: 500
},
persistentValues: {
currency: 'USD',
}
},
{
id: 'UA-YYYYY',
},
],
gtm: [
{
id: 'GTM-XXXXX',
gtmBase: 'https://www.custom.com/gtm.js',
nsBase: 'https://www.custom.com/ns.html',
environment: {
auth: 'X1YzAB2CDEFGh3ijklmnoP',
preview: 'env-x',
},
}
],
pixel: [
{
id: 'XXXXXXX',
}
],
retargeting: [
{
id: 'VK-RTRG-XXXXXX-XXXXX',
}
],
linkedin: [
{
id: 'XXXXXXX',
}
],
tongji: [
{
id: 'XXXXXXX',
}
],
metrica: [
{
id: 'XXXXXXX',
config: {
defer: true,
clickmap: true,
trackLinks: true,
accurateTrackBounce: true,
childIframe: true,
webvisor: true,
trackHash: true,
triggerEvent: true,
ecommerce: 'dataLayer',
trustedDomains: ['example.com'],
type: 0,
params: {},
userParams: {}
}
}
],
microsoft: {
id: 'XXXXX'
},
microsoftClarity: {
id: 'XXXXX'
},
hotjar: {
id: 1000000
},
fullStory: {
org: 'X-XXXXXX-XXX',
host: 'fullstory.com',
script: 'edge.fullstory.com/s/fs.js',
namespace: 'FS',
},
unbounce: {
enabled: true,
script: 'd3pkntwtp2ukl5.cloudfront.net/uba.js'
},
tiktok: {
id: 1000000,
script: 'analytics.tiktok.com/i18n/pixel/events.js'
},
simpleanalytics: {
enabled: true,
hostname: 'example.com',
script: 'https://example.com/proxy.js',
noScript: 'https://example.com/simple/noscript.gif'
},
posthog: {
enabled: true,
token: 'phc_XXXXXXXXXXXXXXXXXXXXXXXX',
api_host: 'https://us.i.posthog.com',
config: {},
},
plausible: {
enabled: true,
hostname: 'example.com',
script: 'example.com/js/script.js',
},
})
],
}
Resources