}, false);
};
-cubistga.prototype.event = function (action, category, label, value, noninteraction) {
+cubistga.prototype.addToCart = function (id, name, quantity) {
+ this.event('add_to_cart', 'ecommerce', null, null, false, {
+ items: [
+ {id: id, name: name, quantity: quantity}
+ ]
+ });
+};
+
+cubistga.prototype.removeFromCart = function (id, name, quantity) {
+ this.event('remove_from_cart', 'ecommerce', null, null, false, {
+ items: [
+ {id: id, name: name, quantity: quantity}
+ ]
+ });
+};
+
+cubistga.prototype.event = function (action, category, label, value, noninteraction, options) {
if (noninteraction === undefined) {
noninteraction = false;
}
- let options = {non_interaction: noninteraction};
+ if (options === undefined) {
+ options = {};
+ }
+ options.non_interaction = noninteraction;
if (undefined !== category && null !== category) {
options.event_category = category;
}
if (undefined !== value && null !== value) {
options.value = value;
}
+ console.log('gtag event',action,options);
return gtag('event', action, options)
};