Hi there,
I’m new to amplitude and don’t really know much code. I’m trying to instrument an event for when a specific item on a squarespace shop page is added to cart.
First, I got the elementID by using the inspect function on the web page, and then I am using this code via the squarespace header code injection tool to try and send the data to amplitude:
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function () {
// Identify the button element
var addToCartButton = document.getElementById('elementidremovedforprivacy');
// Attach click event listener
addToCartButton.addEventListener('click', function () {
// Log the event to Amplitude
amplitude.getInstance().logEvent('Item Added to Cart');
});
});
</script>
But I’m not seeing any of the events pushed to my amplitude data stream. Do I need to set something up in Amplitude to listen for the event, or is there something wrong with my code? I had ChatGPT proof it and it said there were no errors, but still nothing. Any help would be appreciated.