LinkedIn Insight Tag
The LinkedIn Insight Tag tracks conversions and sends audience signals to LinkedIn Ads.
useScriptLinkedInInsight() registers the partner ID and exposes the lintrk command queue.
Nuxt Config Setup
Add this to your nuxt.config.ts to load LinkedIn Insight Tag globally. Alternatively you can use the useScriptLinkedInInsight composable for more control.
export default defineNuxtConfig({
scripts: {
registry: {
linkedinInsight: {
trigger: 'onNuxtReady',
}
}
}
})This config automatically enables first-party mode (bundle + proxy). See below to customise.
useScriptLinkedInInsight()
The useScriptLinkedInInsight composable lets you have fine-grain control over when and how LinkedIn Insight Tag is loaded on your site.
const { proxy } = useScriptLinkedInInsight()Please follow the Registry Scripts guide to learn more about advanced usage.
First-Party Mode: Privacy Focused Proxy
No extra config needed. The script is bundled from your domain (faster loads, no extra DNS lookup) and runtime requests are reverse-proxied through your server with automatic anonymisation (user IPs stay hidden from LinkedIn Insight Tag, works with ad blockers). Learn more.
export default defineNuxtConfig({
scripts: {
// ✅ First-party mode: bundled + proxied
registry: {
linkedinInsight: {
trigger: 'onNuxtReady',
},
},
},
})Example
Using LinkedIn Insight Tag in a component with the proxy to send events .
<script setup lang="ts">
const { proxy } = useScriptLinkedInInsight()
// noop in development, ssr
// just works in production, client
function handleAction() {
// use proxy methods here
}
</script>
<template>
<div>
<button @click="handleAction">
Send Event
</button>
</div>
</template>idstring | string[] required Your LinkedIn Insight Tag Partner ID, or an array of Partner IDs to push onto window._linkedin_data_partner_ids. The first ID is used as the primary _linkedin_partner_id global.
eventIdstringOptional page-load event ID for Conversions API deduplication. Assigned to window._linkedin_event_id BEFORE the Insight Tag base code runs. Must match the eventId sent with the corresponding server-side Conversions API event. Per-event conversion deduplication uses the per-call event_id passed to lintrk('track', { conversion_id, event_id }) instead.
enableAutoSpaTrackingboolean = falseAuto-fire lintrk('track') on Vue Router route changes (SPA virtual page views). When true, suppresses the script's built-in auto-page-view via window._wait_for_lintrk and tracks every navigation including the initial page through Nuxt's page:finish hook. When false, the script fires its own page-view exactly once on load and SPA navigations are not tracked unless lintrk('track') is called manually.
Examples
Tracking a conversion
<script setup lang="ts">
const { proxy } = useScriptLinkedInInsight({
id: '111143',
})
function trackPurchase() {
proxy.lintrk('track', { conversion_id: 1111111177 })
}
</script>
Per-event deduplication with the Conversions API
When you also send conversions through LinkedIn's server-side Conversions API, pass the same event_id to both. LinkedIn discards the server-side duplicate and counts the Insight Tag event. See LinkedIn deduplication.
<script setup lang="ts">
const { proxy } = useScriptLinkedInInsight({
id: '111143',
})
function trackSignup() {
const eventId = crypto.randomUUID()
proxy.lintrk('track', { conversion_id: 1111111177, event_id: eventId })
// Send the same eventId to your server-side Conversions API call.
}
</script>
Page-load conversion deduplication
For dedup on the auto-fired page-view, set eventId at registration. The composable assigns window._linkedin_event_id before the Insight Tag base code runs, so the page-view URL includes &eventId=… automatically.
<script setup lang="ts">
useScriptLinkedInInsight({
id: '111143',
eventId: 'page-load-event-id-123',
})
</script>
Enhanced matching with setUserData
Pass plain email; the Insight Tag SHA-256 hashes it on-device. See LinkedIn enhanced matching.
<script setup lang="ts">
const { proxy } = useScriptLinkedInInsight({
id: '111143',
})
function onSignupSuccess(email: string) {
proxy.lintrk('setUserData', { email })
}
</script>
SPA virtual page views
By default, the Insight Tag fires a page-view exactly once when the script loads, so SPA route changes go untracked. Opt in to per-route tracking with enableAutoSpaTracking:
<script setup lang="ts">
useScriptLinkedInInsight({
id: '111143',
enableAutoSpaTracking: true,
})
</script>
When enabled, the composable suppresses the script's built-in automatic page view (with window._wait_for_lintrk = true) and fires lintrk('track') on Nuxt's page:finish hook. Under the standard <NuxtPage /> lifecycle, this produces one /collect beacon for each route, including the initial page. Keep-alive or overlapping page transitions can register multiple hooks, so call the composable once from a long-lived component in those setups.
Multiple partner IDs
If you need to push more than one Partner ID onto window._linkedin_data_partner_ids, pass an array. The composable promotes the first ID to the primary _linkedin_partner_id global.
<script setup lang="ts">
useScriptLinkedInInsight({
id: ['111143', '111154'],
})
</script>