SEO, AdWords, affiliates, advertising, and promotions
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hello Shopify Developer Community,
I am experiencing an issue with the add_to_cart event when using the Ajax API in our app. Here are the details:
Context:
Our app uses the Shopify Add to Cart Ajax API to manage cart additions when a merchant applies a volume discount offer. The app is intended to trigger a single add_to_cart event each time items are added, based on the Shopify documentation. However, we have encountered a situation where the add_to_cart event is triggered multiple times in the Shopify dataLayer, even though our code only calls the Ajax API once.
Steps Taken:
- We’ve confirmed that the API is called only once per cart addition, regardless of quantity or variant type.
- Tested different scenarios (e.g., adding items with the same variant and adding items with different variants) and observed a single Ajax API call each time.
- Despite this, multiple add_to_cart events appear in the dataLayer, affecting analytics.
Questions:
1. Has anyone encountered similar issues with the add_to_cart event triggering multiple times in the dataLayer when using the Ajax API?
2. Are there specific conditions or settings in the Shopify ecosystem that might cause this behavior?
3. Any troubleshooting advice or recommendations for resolving this discrepancy?
Supporting Material:
Here’s a Loom video showing the behavior we observed during testing.
Here's a link to the offer where this issue can be reproduced - https://consolatio.com.br/products/kit-3-camisas-ultra-stretch
Additional Information:
- Shopify API Version: 2023-07
- API Type: Ajax API
- App Language: JavaScript
Thank you in advance for any insights or advice you may have. I appreciate any guidance from those who may have faced similar issues or have expertise with Shopify’s Ajax API.
Cheers,
Ohad
Hello Enon,
Thank you for your response and suggestions. I have conducted further testing and have found additional insights into this issue. The problem seems to manifest specifically under the following condition:
Do you think it could still be any of these points mentioned?