In addition to installing the retargeting pixel code on your website, it is necessary to specify parameters and types of events for which audience data will be collected. You can read technical documentation for installing a pixel
here. For correct operation, you will need PIXEL_ID and price_list_id that you will get while
uploading a price list.
Types of product events,
products_event parameter:
- view_home � to view the homepage;
- view_category � to view the catalogue categories;
- view_product � to view the product card;
- view_search � to view the search page;
- view_other � to view any other pages;
- add_to_wishlist � to add products to the wishlist;
- add_to_cart � to add products to the cart;
- remove_from_wishlist � to remove products from the wishlist;
- remove_from_cart � to remove products from the cart;
- init_checkout � to start purchasing;
- add_payment_info � to enter payment information;
- purchase � to make a purchase.
Parameters:
- products: array // optional, example: [{"id":"123","recommended_ids":"23,44"}] A list of products with additional information on them, with a description of the product type below.
- products_recommended_ids: string // optional, example: qwe789,rty777 A list of recommended products, when there are no specific goods or you want to recommend some products without reference to any specific goods.
- category_ids: string // optional, example: 12,23,34 A list of product categories, when there are no specific goods or you want to cover some additional category completely.
- business_value: int // optional, example: 1000 The value of this event for business in notional units, from 1 to 1,000,000.
- currency_code: string // optional, example: RUR Currency for the price and price_old fields.
- total_price: int // optional, example: 3000 The total cost of goods from the products field.
- search_string: string // optional, example: ����� ��� �������� A user�s search query.
It is highly desirable that for most events (even
view_home) one of the products fields,
category_ids, products_recommended_ids, be filled.
Fields of the product object:
- id: string // example: abc123 Product ID from the price list.
- group_id: string // optional, example: 22 Group of products. Is the user is viewing not a specific model, but all variants of the model.
- recommended_ids: string // optional, example: qwe789,rty777 ID of recommended products for a specific product or group of products.
- price: int // optional, example: 1000 Special price for a specific product or group of products for a certain user.
- price_old: int // optional, example: 2000 Old price for the user. Counted if the price field is set.
- price_from: bool // optional, example: 1 If set, the price field specifies the price �from�. Counted if the price field is set.
Call example:
First connect
vk.com/js/api/openapi.js and initialize the pixel using
VK.Retargeting.Init()
// PHASE I: Initialisation phase
<div id="vk_api_transport"></div>
<script type="text/javascript">
window.vkAsyncInit = function() {
VK.Retargeting.Init(
PIXEL_ID);
};
setTimeout(function() {
var el = document.createElement("s�ript");
el.type = "text/javascript";
el.src = "
vk.com/js/api/openapi.js?150";;
el.async = true;
document.getElementById("vk_api_transport").appendChild(el);
}, 0);
</script>
// PHASE II: When product event should be fired
// Detailed info (in Russian)
https://vkcom.github.io/vk-ads-retargeting-demo/index.html
const eventParams = {
"products" : [{"id":"456", "recommended_ids":"abc456,def789"}, {"id":"672", "group_id":"678","recommended_ids":"abc456,def789"}],
"products_recommended_ids" : "55,166,754",
"business_value" : 88,
"total_price" : 34899
};
VK.Retargeting.ProductEvent(
PRICE_LIST_ID, "view_product", eventParams);
Detailed call description:
VK.Retargeting.ProductEvent(PRICE_LIST_ID, products_event, { <parameters> });
price_list_id: int // ex: 12345 // Price list ID.
products_event: string // ex: view_product // Product action type (see above).