使用此插件
addProductEvent
函数使用以下参数:
en
(必需,字符串):要添加到products
变量中最后一个条目的事件。如果products
变量为空,则会创建一个“空白”产品条目,并附加事件(及其值)。ev
(必需,字符串):分配给en
参数中的数值或货币事件的值。如果未设置,则默认为1
。未包含在字符串引号中的数字也是有效的。ap
(可选,布尔值):如果产品变量当前包含多个产品条目,则值为true
(或1
)会将事件添加到所有产品条目。如果未设置,则默认为false
。
addProductEvent
不会返回任何结果。而是将事件及其值添加到 products
变量。该插件还会自动将事件添加到 events
变量中,因为此变量也需要该事件。
Cookie
addProductEvent
函数不会创建或使用任何 Cookie。
示例
// Sets the products variable to ";product1;3;300,;product2;2;122,;product3;1;25;event35=25".
// Also sets the events variable to "purchase,event35".
s.products = ";product1;3;300,;product2;2;122,;product3;1;25";
s.events = "purchase";
addProductEvent("event35", "25");
// Sets the products variable to ";product1;3;300;event35=25,;product2;2;122;event35=25,;product3;1;25;event35=25".
s.products = ";product1;3;300,;product2;2;122,;product3;1;25";
addProductEvent("event35", 25, true);
// Sets the products variable to ";product1;3;300;event2=10;eVar33=large|eVar34=men|eVar35=blue,;product2;2;122,;product3;1;25;event33= 12|event34=10|event35=15"
// Also sets the s.events variable to "purchase,event2,event33,event34,event35".
s.products=";product1;3;300;event2=10;eVar33=large|eVar34=men|eVar35=blue,;product2;2;122,;product3;1;25";
s.events="purchase,event2";
addProductEvent("event33", "12");
addProductEvent("event34", "10");
addProductEvent("event35", "15");
// Sets the products variable to ";product1;3;300;event2=10|event33=12|event34=10|event35=15;eVar33=large|eVar34=men|eVar35=blue,;product2;2;122;event33=12|event34=10|event35=15,;product3;1;25;event33=12|event34=10|event35=15".
// Also sets the events variable to "purchase,event2,event33,event34,event35".
s.products=";product1;3;300;event2=10;eVar33=large|eVar34=men|eVar35=blue,;product2;2;122,;product3;1;25"
s.events="purchase,event2"
addProductEvent("event33", "12", 1);
addProductEvent("event34", 10, 1);
addProductEvent("event35", "15", 1);
// If the products variable isn't already set, sets it to ";;;;event35=25".
// Also appends event35 to the events variable.
addProductEvent("event35", "25");
版本历史记录
2.0(2021 年 3 月 19 日)
- 以上下文数据形式添加了版本号。
1.0(2019 年 10 月 7 日)
- 第一版。