@blotoutio/providers-google-analytics-4-sdk 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +16 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -36,18 +36,31 @@ var ProvidersGoogleAnalytics4Sdk = (function () {
36
36
  const getItems = (contents = []) => {
37
37
  return contents.map((content) => {
38
38
  const data = {
39
- item_id: content.id,
39
+ item_id: content.id.toString(),
40
40
  quantity: content.quantity || 1,
41
41
  };
42
42
  if (content.title) {
43
43
  data['item_name'] = content.title;
44
44
  }
45
45
  if (content.category) {
46
- data['item_category'] = content.category;
46
+ const categories = content.category.split(',');
47
+ data['item_category'] = categories[0];
48
+ for (let i = 1; i < Math.min(categories.length, 5); i++) {
49
+ if (categories[i].trim()) {
50
+ data[`item_category${i + 1}`] =
51
+ categories[i].trim();
52
+ }
53
+ }
47
54
  }
48
55
  if (content.item_price) {
49
56
  data['price'] = content.item_price;
50
57
  }
58
+ if (content.brand) {
59
+ data['item_brand'] = content.brand;
60
+ }
61
+ if (content.variantId) {
62
+ data['item_variant'] = content.variantId.toString();
63
+ }
51
64
  return data;
52
65
  });
53
66
  };
@@ -243,7 +256,7 @@ var ProvidersGoogleAnalytics4Sdk = (function () {
243
256
  }
244
257
  return {
245
258
  loaded: isLoaded,
246
- sdkVersion: "0.13.0" ,
259
+ sdkVersion: "0.15.0" ,
247
260
  };
248
261
  };
249
262
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-google-analytics-4-sdk",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "description": "Google Analytics 4 Browser SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",