Track more events
- addToCart with product name - cartOpen - cartCheckout when going to checkout page
This commit is contained in:
@@ -6,12 +6,14 @@
|
|||||||
import { scale } from 'svelte/transition'
|
import { scale } from 'svelte/transition'
|
||||||
import { quartOut } from 'svelte/easing'
|
import { quartOut } from 'svelte/easing'
|
||||||
import { cartOpen, cartAmount } from '$utils/stores/shop'
|
import { cartOpen, cartAmount } from '$utils/stores/shop'
|
||||||
|
import { sendEvent } from '$utils/analytics'
|
||||||
// Components
|
// Components
|
||||||
import Icon from '$components/atoms/Icon.svelte'
|
import Icon from '$components/atoms/Icon.svelte'
|
||||||
import ButtonCircle from '$components/atoms/ButtonCircle.svelte'
|
import ButtonCircle from '$components/atoms/ButtonCircle.svelte'
|
||||||
|
|
||||||
const openCart = () => {
|
const openCart = () => {
|
||||||
$cartOpen = true
|
$cartOpen = true
|
||||||
|
sendEvent('cartOpen')
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
import Icon from '$components/atoms/Icon.svelte'
|
import Icon from '$components/atoms/Icon.svelte'
|
||||||
import CartItem from '$components/molecules/CartItem.svelte'
|
import CartItem from '$components/molecules/CartItem.svelte'
|
||||||
import ShopLocationSwitcher from '$components/molecules/ShopLocationSwitcher.svelte'
|
import ShopLocationSwitcher from '$components/molecules/ShopLocationSwitcher.svelte'
|
||||||
|
import { sendEvent } from '$utils/analytics';
|
||||||
|
|
||||||
|
|
||||||
// Block scroll if cart is open
|
// Block scroll if cart is open
|
||||||
@@ -139,6 +140,7 @@
|
|||||||
text="Checkout"
|
text="Checkout"
|
||||||
color="pink"
|
color="pink"
|
||||||
size="small"
|
size="small"
|
||||||
|
on:click={() => sendEvent('cartCheckout', { props: { amount: $cartAmount }})}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -44,7 +44,9 @@ export const addToCart = async (product: any, quantity: number = 1) => {
|
|||||||
|
|
||||||
// Send event
|
// Send event
|
||||||
sendEvent('addToCart', {
|
sendEvent('addToCart', {
|
||||||
product: product.name
|
props: {
|
||||||
|
product: product.name,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user