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"><br /> document.addEventListener('DOMContentLoaded', function () {<br /> // Identify the button element<br /> var addToCartButton = document.getElementById('elementidremovedforprivacy');<br /> // Attach click event listener<br /> addToCartButton.addEventListener('click', function () {<br /> // Log the event to Amplitude<br /> amplitude.getInstance().logEvent('Item Added to Cart');<br /> });<br /> });<br /></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.