1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "events": [
12 {
13 "name": "purchase",
14 "params": {
15 "transaction_id": "SYNTHETIC-001",
16 "currency": "EUR",
17 "value": 25,
18 "tax": 5,
19 "shipping": 2,
20 "items": [
21 {
22 "item_id": "SKU-01",
23 "price": 10,
24 "quantity": 2
25 },
26 {
27 "item_name": "Blue mug",
28 "price": 5
29 }
30 ]
31 }
32 },
33 {
34 "name": "purchase",
35 "params": {
36 "transaction_id": "SYNTHETIC-002",
37 "currency": "EUR",
38 "value": 32,
39 "tax": 5,
40 "shipping": 2,
41 "items": [
42 {
43 "item_id": "SKU-01",
44 "price": 10,
45 "quantity": 2
46 },
47 {
48 "item_name": "Blue mug",
49 "price": 5
50 }
51 ]
52 }
53 },
54 {
55 "name": "add_to_cart",
56 "params": {
57 "value": 1,
58 "items": [
59 {
60 "item_id": "SKU-01",
61 "price": 1,
62 "quantity": 1
63 }
64 ]
65 }
66 },
67 {
68 "name": "refund",
69 "params": {
70 "transaction_id": "OUTSIDE-THIS-SYNTHETIC-SAMPLE",
71 "value": 5,
72 "currency": "EUR"
73 }
74 }
75 ]
76};
77
78
79const run = await client.actor("danielmichalek/ga4-ecommerce-event-auditor").call(input);
80
81
82console.log('Results from dataset');
83console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
84const { items } = await client.dataset(run.defaultDatasetId).listItems();
85items.forEach((item) => {
86 console.dir(item);
87});
88
89