---
title: "Snapchat Pixel · Nuxt Scripts"
description: "Use Snapchat Pixel in your Nuxt app."
canonical_url: "https://scripts.nuxt.com/scripts/v0/tracking/snapchat-pixel"
meta:
  "og:description": "Use Snapchat Pixel in your Nuxt app."
  "og:image": "https://scripts.nuxt.com/_og/d/c_Docs%2Ctitle_Snapchat%2BPixel%2Cdescription_Use%2BSnapchat%2BPixel%2Bin%2Byour%2BNuxt%2Bapp.%2Cheadline_Tracking%2Cp_Ii9zY3JpcHRzL3YwL3RyYWNraW5nL3NuYXBjaGF0LXBpeGVsIg%2Cs_vH4auYAEaNuqJf1k.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "Snapchat Pixel · Nuxt Scripts"
  "twitter:image": "https://scripts.nuxt.com/_og/d/c_Docs%2Ctitle_Snapchat%2BPixel%2Cdescription_Use%2BSnapchat%2BPixel%2Bin%2Byour%2BNuxt%2Bapp.%2Cheadline_Tracking%2Cp_Ii9zY3JpcHRzL3YwL3RyYWNraW5nL3NuYXBjaGF0LXBpeGVsIg%2Cs_vH4auYAEaNuqJf1k.png"
---

> Index of every page on this site: [llms.txt](https://scripts.nuxt.com/llms.txt)

**Tracking**

# **Snapchat Pixel**

[Copy for LLMs](https://scripts.nuxt.com/scripts/v0/tracking/snapchat-pixel.md)

[**Snapchat Pixel**](https://businesshelp.snapchat.com/s/article/snap-pixel-about) lets you measure the crossdevice impact for your Snapchat ad campaigns.

Nuxt Scripts provides a registry script composable `**useScriptSnapchatPixel**` to easily integrate Snapchat Pixel in your Nuxt app.

### Nuxt Config Setup

The simplest way to load Snpachat Pixel globally in your Nuxt App is to use Nuxt config. Alternatively you can directly use the **useScriptSnapchatPixel** composable.

If you don't plan to send custom events you can use the [**Environment overrides**](https://nuxt.com/docs/getting-started/configuration#environment-overrides) to disable the script in development.

```ts
export default defineNuxtConfig({
  scripts: {
    registry: {
      snapchatPixel: {
        id: 'YOUR_ID'
      }
    }
  }
})
```

#### **With Environment Variables**

If you prefer to configure your id using environment variables.

nuxt.config.ts

```ts
export default defineNuxtConfig({
  scripts: {
    registry: {
      snapchatPixel: true,
    }
  },
  // you need to provide a runtime config to access the environment variables
  runtimeConfig: {
    public: {
      scripts: {
        snapchatPixel: {
          id: '', // NUXT_PUBLIC_SCRIPTS_SNAPCHAT_PIXEL_ID
        },
      },
    },
  },
})
```

.env

```text
NUXT_PUBLIC_SCRIPTS_SNAPCHAT_PIXEL_ID=<YOUR_ID>
```

## useScriptSnapchatPixel

The `**useScriptSnapchatPixel**` composable lets you have fine-grain control over when and how Snapchat Pixel is loaded on your site.

```ts
const { proxy } = useScriptSnapchatPixel({
  id: 'YOUR_ID',
  user_email: 'USER_EMAIL'
})
// example
proxy.snaptr('track', 'PURCHASE', {
  currency: 'USD',
  price: 120.10,
  transaction_id: '11111'
})
```

Please follow the [**Registry Scripts**](https://scripts.nuxt.com/docs/v0/guides/registry-scripts) guide to learn more about advanced usage.

### SnapchatPixelApi

```ts
export interface SnapPixelApi {
  snaptr: SnapTrFns & {
    push: SnapTrFns
    loaded: boolean
    version: string
    queue: any[]
  }
  _snaptr: SnapPixelApi['snaptr']
  handleRequest?: SnapTrFns
}
type StandardEvents = 'PAGE_VIEW' | 'VIEW_CONTENT' | 'ADD_CART' | 'SIGN_UP' | 'SAVE' | 'START_CHECKOUT' | 'APP_OPEN' | 'ADD_BILLING' | 'SEARCH' | 'SUBSCRIBE' | 'AD_CLICK' | 'AD_VIEW' | 'COMPLETE_TUTORIAL' | 'LEVEL_COMPLETE' | 'INVITE' | 'LOGIN' | 'SHARE' | 'RESERVE' | 'ACHIEVEMENT_UNLOCKED' | 'ADD_TO_WISHLIST' | 'SPENT_CREDITS' | 'RATE' | 'START_TRIAL' | 'LIST_VIEW'
type SnapTrFns =
  ((event: 'track', eventName: StandardEvents | '', data?: EventObjectProperties) => void) &
  ((event: 'init', id: string, data?: Record<string, any>) => void) &
  ((event: 'init', id: string, data?: InitObjectProperties) => void) &
  ((event: string, ...params: any[]) => void)
interface EventObjectProperties {
  price?: number
  client_dedup_id?: string
  currency?: string
  transaction_id?: string
  item_ids?: string[]
  item_category?: string
  description?: string
  search_string?: string
  number_items?: number
  payment_info_available?: 0 | 1
  sign_up_method?: string
  success?: 0 | 1
  brands?: string[]
  delivery_method?: 'in_store' | 'curbside' | 'delivery'
  customer_status?: 'new' | 'returning' | 'reactivated'
  event_tag?: string
  [key: string]: any
}
interface InitObjectProperties {
  user_email?: string
  ip_address?: string
  user_phone_number?: string
  user_hashed_email?: string
  user_hashed_phone_number?: string
  firstname?: string
  lastname?: string
  geo_city?: string
  geo_region?: string
  geo_postal_code?: string
  geo_country?: string
  age?: string
}
```

### Config Schema

You must provide the options when setting up the script for the first time.

```ts
export const SnapTrPixelOptions = object({
  id: string(),
  trackPageView: optional(boolean()),
  user_email: optional(string()),
  ip_address: optional(string()),
  user_phone_number: optional(string()),
  user_hashed_email: optional(string()),
  user_hashed_phone_number: optional(string()),
  firstname: optional(string()),
  lastname: optional(string()),
  geo_city: optional(string()),
  geo_region: optional(string()),
  geo_postal_code: optional(string()),
  geo_country: optional(string()),
  age: optional(string()),
})
```

## Example

Using Snapchat Pixel only in production while using `**snaptr**` to send a conversion event.

```vue
<script setup lang="ts">
const { proxy } = useScriptSnapchatPixel()

// noop in development, ssr
// just works in production, client
function sendConversion() {
  proxy.snaptr('track', 'PURCHASE', {
    currency: 'USD',
    price: 120.10,
    transaction_id: '11111'
  })
}
</script>

<template>
  <div>
    <button @click="sendConversion">
      Send Conversion
    </button>
  </div>
</template>
```

[Edit this page](https://github.com/nuxt/scripts/edit/0.x/docs/content/tracking/snapchat-pixel.md)

[Markdown For LLMs](https://scripts.nuxt.com/scripts/v0/tracking/snapchat-pixel.md)

[**Segment** Use Segment in your Nuxt app.](https://scripts.nuxt.com/scripts/v0/tracking/segment) [**X Pixel** Use X Pixel in your Nuxt app.](https://scripts.nuxt.com/scripts/v0/tracking/x-pixel)

**On this page **

- [Nuxt Config Setup](#nuxt-config-setup)
- [useScriptSnapchatPixel](#usescriptsnapchatpixel)
- [Example](#example)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://scripts.nuxt.com/#website","@type":"WebSite","description":"Nuxt Scripts lets you load third-party scripts with better performance, privacy, security and DX. It includes many popular third-parties out of the box.","name":"Nuxt Scripts","url":"https://scripts.nuxt.com/","publisher":{"@id":"https://scripts.nuxt.com/#identity"}},{"@id":"https://scripts.nuxt.com/scripts/v0/tracking/snapchat-pixel#webpage","@type":"WebPage","description":"Use Snapchat Pixel in your Nuxt app.","name":"Snapchat Pixel","url":"https://scripts.nuxt.com/scripts/v0/tracking/snapchat-pixel","breadcrumb":{"@id":"https://scripts.nuxt.com/scripts/v0/tracking/snapchat-pixel#breadcrumb"},"isPartOf":{"@id":"https://scripts.nuxt.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://scripts.nuxt.com/scripts/v0/tracking/snapchat-pixel"]}],"primaryImageOfPage":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/#identity","@type":"Organization","name":"Nuxt Scripts","url":"https://scripts.nuxt.com","logo":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/scripts/v0/tracking/snapchat-pixel#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Nuxt Scripts","item":"https://scripts.nuxt.com/","position":1},{"@type":"ListItem","name":"Scripts","item":"https://scripts.nuxt.com/scripts","position":2},{"@type":"ListItem","name":"V0","item":"https://scripts.nuxt.com/scripts/v0","position":3},{"@type":"ListItem","name":"Tracking","item":"https://scripts.nuxt.com/scripts/v0/tracking","position":4},{"@type":"ListItem","name":"Snapchat Pixel","item":"https://scripts.nuxt.com/scripts/v0/tracking/snapchat-pixel","position":5}]},{"@id":"https://scripts.nuxt.com/#logo","@type":"ImageObject","caption":"Nuxt Scripts","contentUrl":"https://scripts.nuxt.com/logo.svg","inLanguage":"en","url":"https://scripts.nuxt.com/logo.svg"}]}
```

## Sitemap

See the full [sitemap](https://scripts.nuxt.com/sitemap.md) for all pages.
