Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Warning

If you offer different product variations (such as size, colour, material, etc) than your integration will slightly be different, please follow the guidelines on the Product Variant page.

...

There are 2 methods to send Cart Update event to RMC:

  1. Send all cart data in one time.

  2. Send data of last product added, removed or changed quantity.

We recommend you to use method 1. Because it allows you use our tool much more effective.

Sending All Cart Data in One Time

Use this code when a product added to cart, removed from cart and change quantity of a product that added to cart. 

Note

You must send all cart content every time you execute the cart scriptafter updates.

Code Block
languagejs
linenumberstrue
<script type="text/javascript">
function OnVisilabsLoadedrdCart(){
	var VL = new Visilabs(); 
	VL.AddParameter("OM.pbid","Basket ID");
	VL.AddParameter("OM.pb","Product Code1;Product Code2");
	VL.AddParameter("OM.pu" ,"product Quantity 1;product Quantity 2")
	VL.AddParameter("OM.ppr" ,"Product Price1*Product QuanityQuantity 1;Product Price2*Product Quantity2");
	VL.Collect();
}
rdCart();
</script>
Note

You must define OnVisilabsLoaded() before calling it. You can do it by inserting the OnVisilabsLoaded() code before the Visilabs main script.

Note
OnVisilabsLoaded function must be defined only once on every page. When a page has multiple event triggers, for example: Product Page View and Cart Update(Add to/Remove from Cart)event can be triggered on same page; 2 functions must be defined with different names. In this case, since the OnVisilabsLoaded name defined for Product Page View, function name for Cart Update(Add to/Remove from Cart) event must be something else and this function must be called when Cart Update(Add to/Remove from Cart) event triggers.
Example function definition and call for Cart Update(Add to/Remove from Cart) event:

definition: function rdAddtoCart() {
  ...
}
call: rdAddtoCart();

For example:

User has already have a product and add another product to cart. 

Basket ID of user: "A1B2C3"

First Product: 

id: "123"

price: $30

quantity: 2

Second Product:

id: "456"

price: $40

quantity: 3

Your code should be like this.

Code Block
languagejs
<script type="text/javascript">
function rdCart(){
	var VL = new Visilabs(); 
	VL.AddParameter("OM.pbid","A1B2C3");
	VL.AddParameter("OM.pb","123;456");
	VL.AddParameter("OM.pu" ,"2;3")
	VL.AddParameter("OM.ppr" ,"60;120");
	VL.Collect();
}
rdCart();
</script>
Note

You must pass the total revenue value to OM.ppr parameter which is the number of items purchased multiplied by the price of a single item.


Sending Data of Last Item that Added, Removed or Changed Quantity

Use this code when a product added to cart, removed from cart and change quantity of a product that added to cart. 

Code Block
languagejs
linenumberstrue
<script type="text/javascript">
function rdCart(){
	var VL = new Visilabs(); 
	VL.AddParameter("OM.pb","Product Code");
	VL.AddParameter("OM.pu" ,"Change in Product Quantity") 
	VL.AddParameter("OM.ppr" ,"Product Price");
	VL.Collect();
}
rdCart();
</script>



Note

In this method, quantity parameter takes the change in quantity.

Examples for each case:

  • If you add 3 of the same product it should be 3.
  • If you remove that product from the cart, it should be -3.
  • If you change quantity of a product that already 2 of it in cart to 4, value should be 2.
Note

Do not use thousands separator when sending numbers. Wrong: 123.456,78 Correct: 123456,78

Note

You must pass the total revenue value to OM.ppr parameter which is the number of items purchased multiplied by the price of a single item.


...

Parent Topic: Website ImplementationYou must define OnVisilabsLoaded() before calling it. You can do it by inserting the OnVisilabsLoaded() code before the Visilabs main script.