TLDR: Snapchat Pixel requires consent for EU users. GetCookies blocks it until marketing consent using a simple data attribute. Essential for Gen Z advertising.
Read full summary
Snapchat advertising reaches younger demographics that other platforms miss. The Snap Pixel requires proper consent handling in the EU. This guide shows how to implement it correctly.
Summary by Claude AI
Reaching Gen Z? You Need Compliant Tracking
Snapchat is where Gen Z lives. If your audience skews young, Snapchat ads are essential.
But like every other platform, Snap Pixel requires consent in the EU. Fire it without permission, and you're breaking the law.
The GetCookies Implementation
<head>
<!-- GetCookies -->
<script src="https://getcookies.co/api/v1/widget/loader.js"
data-domain-id="YOUR_DOMAIN_ID"
async></script>
<!-- Snapchat Pixel - only after marketing consent -->
<script type="text/plain" data-cookieconsent="marketing">
(function(e,t,n){
if(e.snaptr)return;
var a=e.snaptr=function(){
a.handleRequest?a.handleRequest.apply(a,arguments):a.queue.push(arguments)
};
a.queue=[];
var s='script';
var r=t.createElement(s);r.async=!0;
r.src=n;
var u=t.getElementsByTagName(s)[0];
u.parentNode.insertBefore(r,u);
})(window,document,'https://sc-static.net/scevent.min.js');
snaptr('init', 'YOUR_PIXEL_ID', {
'user_email': '__INSERT_USER_EMAIL__'
});
snaptr('track', 'PAGE_VIEW');
</script>
</head>
The type="text/plain" blocks execution. GetCookies activates it after marketing consent.
Event Tracking
After consent:
// Page view
snaptr('track', 'PAGE_VIEW');
// Purchase
snaptr('track', 'PURCHASE', {
'currency': 'USD',
'price': 99.99,
'transaction_id': 'order_123'
});
// Add to cart
snaptr('track', 'ADD_CART', {
'currency': 'USD',
'price': 29.99,
'item_ids': ['SKU123']
});
// Sign up
snaptr('track', 'SIGN_UP');
// Custom event
snaptr('track', 'CUSTOM_EVENT_1');
Dynamic Loading Pattern
window.addEventListener('getcookies:consent', (e) => {
if (e.detail.marketing && !window.snapLoaded) {
loadSnapPixel();
window.snapLoaded = true;
}
});
function loadSnapPixel() {
(function(e,t,n){
if(e.snaptr)return;
var a=e.snaptr=function(){
a.handleRequest?a.handleRequest.apply(a,arguments):a.queue.push(arguments)
};
a.queue=[];
var s='script';var r=t.createElement(s);r.async=!0;
r.src=n;var u=t.getElementsByTagName(s)[0];
u.parentNode.insertBefore(r,u);
})(window,document,'https://sc-static.net/scevent.min.js');
snaptr('init', 'YOUR_PIXEL_ID');
snaptr('track', 'PAGE_VIEW');
}
Snapchat Conversions API (Server-Side)
For better attribution:
import requests
import hashlib
url = "https://tr.snapchat.com/v2/conversion"
headers = {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"Content-Type": "application/json"
}
payload = {
"pixel_id": "YOUR_PIXEL_ID",
"timestamp": "1640000000000",
"event_type": "PURCHASE",
"event_conversion_type": "WEB",
"hashed_email": hashlib.sha256("[email protected]".encode()).hexdigest(),
"price": 99.99,
"currency": "USD"
}
response = requests.post(url, headers=headers, json=payload)
Testing
- Use Snap Pixel Helper extension
- Load site in incognito
- Verify pixel doesn't fire before consent
- Accept marketing cookies, verify events fire
The Bottom Line
Snapchat Pixel needs consent. GetCookies makes it trivial:
- Add
data-cookieconsent="marketing" - Set
type="text/plain" - Pixel only loads after consent
Reach Gen Z. Stay compliant.
Ready to make your Snapchat Pixel compliant?