VK Pixel Integration
VK Pixel (VKontakte pixel) is a tracking tool for VKontakte and myTarget ads. It allows collecting retargeting audiences and tracking conversions from ad campaigns.
Pixel Installation
<script type="text/javascript">
!function(){var t=document.createElement("script");
t.type="text/javascript",t.async=!0,t.src="https://vk.com/js/api/openapi.js?169",
t.onload=function(){VK.Retargeting.Init("VK-RTRG-XXXXXXX-XXXXX"),VK.Retargeting.Hit()},
document.head.appendChild(t)}();
</script>
Standard Events
// Page view (already called via Hit)
VK.Retargeting.Hit();
// Add to cart
VK.Retargeting.Event('add_to_cart');
// Purchase
VK.Retargeting.Event('purchase', {
products: orderItems.map(item => ({
id: item.productId,
name: item.name,
price: item.price,
quantity: item.qty
})),
total_price: orderTotal,
currency_code: 'RUB'
});
// Registration
VK.Retargeting.Event('complete_registration');
Custom Events for Audiences
// Create audience of users who viewed a category
VK.Retargeting.ProductEvent(PRICE_LIST_ID, 'view_category', {
category_id: categoryId
});
// Product view for dynamic retargeting
VK.Retargeting.ProductEvent(PRICE_LIST_ID, 'view_product', {
products: [{ id: productId }]
});
Dynamic retargeting requires a uploaded price list (product feed) in the VK Ads account.
VK Ads Conversions API (Server Pixel)
Http::post('https://api.vk.com/method/ads.createTargetPixelEvent', [
'access_token' => env('VK_ADS_TOKEN'),
'account_id' => env('VK_ADS_ACCOUNT_ID'),
'pixel_id' => env('VK_PIXEL_ID'),
'event_type' => 'purchase',
'price_list_id'=> env('VK_PRICE_LIST_ID'),
'email_hash' => hash('sha256', strtolower($user->email)),
'phone_hash' => hash('sha256', normalizePhone($user->phone)),
'v' => '5.131'
]);
Setup time: a few hours.







