Skip to content

Commit

Permalink
keep it simple
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderkirtzel committed Feb 21, 2025
1 parent 149ac0b commit d7a3dfa
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 50 deletions.
4 changes: 1 addition & 3 deletions packages/destinations/web/google-ads/examples/events.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { WalkerOS } from '@elbwalker/types';
import { getEvent } from '@elbwalker/utils';

export function conversion(custom: WalkerOS.AnyObject = {}) {
export function conversion() {
const event = getEvent('order complete');

return [
Expand All @@ -12,7 +11,6 @@ export function conversion(custom: WalkerOS.AnyObject = {}) {
value: event.data.total,
currency: 'EUR',
transaction_id: event.data.id,
...custom,
},
];
}
7 changes: 2 additions & 5 deletions packages/destinations/web/google-ga4/examples/events.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { WalkerOS } from '@elbwalker/types';
import { getEvent } from '@elbwalker/utils';

export function purchase(custom: WalkerOS.AnyObject = {}) {
export function purchase() {
const event = getEvent('order complete');

return [
Expand All @@ -21,12 +20,11 @@ export function purchase(custom: WalkerOS.AnyObject = {}) {
quantity: 1,
})),
send_to: 'G-XXXXXX-1',
...custom,
},
];
}

export function add_to_cart(custom: WalkerOS.AnyObject = {}) {
export function add_to_cart() {
const event = getEvent('product add');

return [
Expand All @@ -43,7 +41,6 @@ export function add_to_cart(custom: WalkerOS.AnyObject = {}) {
},
],
send_to: 'G-XXXXXX-1',
...custom,
},
];
}
10 changes: 3 additions & 7 deletions packages/destinations/web/google-gtm/examples/events.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import type { WalkerOS } from '@elbwalker/types';
import { getEvent } from '@elbwalker/utils';

export function entity_action(custom: WalkerOS.AnyObject = {}) {
export function entity_action() {
const event = getEvent('entity action');

return {
event: 'entity_action',
data: event.data,
...custom,
};
}

export function purchase(custom: WalkerOS.AnyObject = {}) {
export function purchase() {
const event = getEvent('order complete');

return {
Expand All @@ -28,11 +26,10 @@ export function purchase(custom: WalkerOS.AnyObject = {}) {
item_name: item.data.name,
quantity: 1,
})),
...custom,
};
}

export function add_to_cart(custom: WalkerOS.AnyObject = {}) {
export function add_to_cart() {
const event = getEvent('product add');

return {
Expand All @@ -46,6 +43,5 @@ export function add_to_cart(custom: WalkerOS.AnyObject = {}) {
quantity: 1,
},
],
...custom,
};
}
13 changes: 4 additions & 9 deletions packages/destinations/web/meta-pixel/examples/events.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { WalkerOS } from '@elbwalker/types';
import { getEvent } from '@elbwalker/utils';

export function Purchase(custom: WalkerOS.AnyObject = {}) {
export function Purchase() {
const event = getEvent('order complete');

return [
Expand All @@ -15,12 +14,11 @@ export function Purchase(custom: WalkerOS.AnyObject = {}) {
.map((item) => ({ id: item.data.id, quantity: 1 })),
content_type: 'product',
num_items: 2,
...custom,
},
];
}

export function AddToCart(custom: WalkerOS.AnyObject = {}) {
export function AddToCart() {
const event = getEvent('product add');

return [
Expand All @@ -31,12 +29,11 @@ export function AddToCart(custom: WalkerOS.AnyObject = {}) {
value: event.data.price,
contents: [{ id: event.data.id, quantity: 1 }],
content_type: 'product',
...custom,
},
];
}

export function InitiateCheckout(custom: WalkerOS.AnyObject = {}) {
export function InitiateCheckout() {
const event = getEvent('cart view');

return [
Expand All @@ -52,12 +49,11 @@ export function InitiateCheckout(custom: WalkerOS.AnyObject = {}) {
quantity: entity.data.quantity,
})),
num_items: event.nested.filter((item) => item.type === 'product').length,
...custom,
},
];
}

export function ViewContent(custom: WalkerOS.AnyObject = {}) {
export function ViewContent() {
const event = getEvent('product view');

return [
Expand All @@ -68,7 +64,6 @@ export function ViewContent(custom: WalkerOS.AnyObject = {}) {
value: event.data.value,
contents: [{ id: event.data.id, quantity: 1 }],
content_type: 'product',
...custom,
},
];
}
27 changes: 6 additions & 21 deletions packages/destinations/web/piwikpro/examples/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function getProduct(entity: WalkerOS.Entity | WalkerOS.Event) {
};
}

export function ecommerceOrder(custom: WalkerOS.AnyObject = {}) {
export function ecommerceOrder() {
const event = getEvent('order complete');

return [
Expand All @@ -26,48 +26,33 @@ export function ecommerceOrder(custom: WalkerOS.AnyObject = {}) {
grandTotal: event.data.total,
tax: event.data.taxes,
shipping: event.data.shipping,
...custom,
},
{ currencyCode: 'EUR' },
],
];
}

export function ecommerceAddToCart(custom: WalkerOS.AnyObject = {}) {
export function ecommerceAddToCart() {
const event = getEvent('product add');

return [
[
'ecommerceAddToCart',
[
{
...getProduct(event),
...custom,
},
],
{ currencyCode: 'EUR' },
],
['ecommerceAddToCart', [getProduct(event), ,], { currencyCode: 'EUR' }],
];
}

export function ecommerceProductDetailView(custom: WalkerOS.AnyObject = {}) {
export function ecommerceProductDetailView() {
const event = getEvent('product view');

return [
[
'ecommerceProductDetailView',
[
{
...getProduct(event),
...custom,
},
],
[getProduct(event), ,],
{ currencyCode: 'EUR' },
],
];
}

export function ecommerceCartUpdate(custom: WalkerOS.AnyObject = {}) {
export function ecommerceCartUpdate() {
const event = getEvent('cart view');

return [
Expand Down
7 changes: 2 additions & 5 deletions packages/destinations/web/plausible/examples/events.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { WalkerOS } from '@elbwalker/types';
import { getEvent } from '@elbwalker/utils';

export function purchase(custom: WalkerOS.AnyObject = {}) {
export function purchase() {
const event = getEvent('order complete');

return [
Expand All @@ -21,12 +20,11 @@ export function purchase(custom: WalkerOS.AnyObject = {}) {
quantity: 1,
})),
send_to: 'G-XXXXXX-1',
...custom,
},
];
}

export function add_to_cart(custom: WalkerOS.AnyObject = {}) {
export function add_to_cart() {
const event = getEvent('product add');

return [
Expand All @@ -43,7 +41,6 @@ export function add_to_cart(custom: WalkerOS.AnyObject = {}) {
},
],
send_to: 'G-XXXXXX-1',
...custom,
},
];
}

0 comments on commit d7a3dfa

Please sign in to comment.