Add to Cart event using Shopify and ShineOn integration, Please help!
I’m hoping someone can help me with the add to cart on my Klaviyo. A little background so you know what I’m working with. I use Shopify Debut theme. I POD with ShineOn and they have their own product pages that has a .liquid file in the theme. I’ve watched all the videos and read the articles(the videos and articles are different. The articles say paste in theme.liquid while Youtube videos say product.liquid). Nothing seems to be working. My preview item event is already set up(no code was required since it was just a click of a box. Thank you Klaviyo). One of the issues I’m running into is figuring out the button ID/class. Because I’m using ShineOn for my product pages it has it’s own .liquid file called product.shineon.liquid. This is also the location of the preview item script. When I right-click the add to cart button and inspect, here is the code I have for the button:
<span class="so-btn-add-to-cart-vanity-copy" id="so-btn-add-to-cart-copy">Add to shopping bag </span>
</button> So the big questions are: Am I using button ID or button class? What add to cart variable should I use?Which .liquid file should I paste the code into (theme.liquid, product.liquid, product.shineon.liquid)?
Sorry this is insanely long, I’ve been working all night and can’t get it to work. Thanks for any help!
Page 1 / 1
Hi @tmuldrow,
Thanks for sharing this question with us.
Sorry to hear about the inconsistencies you’ve been experiencing on where to paste the Added to Cart code. The answer (like most things in life) really is - it depends. We (very) recently updated our help center article: How to Create an Added to Cart Event for Shopify that will have the latest up-to-date information. I would use that as your primary point of reference on where to paste your snippet. Specifically, see where should I paste my snippet. I would start with custom.liquid or, if that’s not available, paste the universal snippet into the main theme.liquid file (assuming your add to cart button does not re-direct elsewhere).
I think some confusion on product.liquid vs theme.liquid originated from the “traditional” method of utilizing Added to Cart where we instructed users to paste the snippet (where you adjust the button ID or class) in the same file as Viewed Product which was in the product.liquid file. Our “new” primary method to utilize Added to Cart uses a universal snippet, to be pasted either the custom.liquid block or the theme.liquid file.
So in short, I’d first start by adding the universal snippet into the custom liquid blocks, if that’s not possible, add it to the main theme.liquid file for your theme (should be theme.liquid). This is assuming your button does not re-direct to the cart page. If it does, you should leverage the other snippet in the doc and target the button ID which looks to be: “so-btn-add-to-cart-7686243221717”
<script type="text/javascript"> var _learnq = _learnq || i]; document.getElementById("so-btn-add-to-cart-7686243221717").addEventListener('click',function (){ _learnq.push(i'track', 'Added to Cart', item]); });</script>
I hope that’s helpful.
@Dov thanks so much for your reply! I got it to work! Sort of. I’m now seeing my issue. The button ID has that sequence of numbers on the end. It turns out, that each product has a different set of numbers, making each product have a different Button ID. Is there any way around this? A universal ID so to speak?
Hi @tmuldrow,
Of course, happy to help. I’m glad we’re making progress!
Sort of - instead of trying to target a universal ID (since one doesn’t exist), the best alternative solution is to target the class notation to pull in a class from the button element that exists across all products. Essentially we’re looking for the “common denominator” for class now instead of ID.
So you should have a look (inspect the various “add to cart” buttons) on your site and see which class is “common” across all of them. You may have multiple classes within a single button, each class will be separated by a space, here’s an example of a button with two separate classes (we just want to target the common one across the various buttons).
Insert that common class element into the following snippet (in place of your existing snippet):