So i’ve tried second and third method from this doc as the first one wasn’t working. Both second/third worked with default cart drawer. However, when i installed upcart app for add to cart drawer which disables the default drawer, the add to cart event isn’t triggering in klaviyo.
This is the script i’m using on main-product.liquid in my dawn 12 theme:
<scripttype="text/javascript">var _learnq = _learnq || [];
var classname = document.getElementsByClassName("product-form__submit");
var addToCart = function() {
_learnq.push(['track', 'Added to Cart', item]);
}; for (var i = 0; i < classname.length; i++) {
classname[i].addEventListener('click', addToCart, false);
}
</script>
It’s working fine with default shopify drawer but not with upcart drawer.
I also read another post related to this topic but that said to change the endpoint in the script from /cart/add.js to /cart/add.js?upcart=1 but i can’t seem to find these endpoints in my script.
Best answer by StefanUE
@Daddy hey, thanks for your question and welcome to the community!
You’ve installed Snippet 3, is that correct?
Below the instructions on how to implement that snippet, you’ll also find this: This snippet will likely need to be modified, because the Add to Cart variable in the snippet needs to match the class used on your site.
Open up one of your site’s product pages.
Right-click your "Add to Cart" button and select Inspect.
The console will open, showing the source code of your "Add to Cart" button. The following image shows the class of the "Add to Cart" button highlighted in the console.
Compare your button code in between the quotations, highlighted in the above example, with the contents in between the parentheses after getElementsByClassName in the code snippet above. For example, the class listed in the screenshot is btn product-form_cart-submit btn--secondary-accent and the variable listed in the snippet is add-to-cart.
If they don’t match, modify the snippet to match the class of your button. Our example’s modified snippet looks like this:
Perhaps installing Upcart changes the class name in your snippet, so you basically just have to repeat the whole process after switching it on, then trying again to see if it works.
@Daddy hey, thanks for your question and welcome to the community!
You’ve installed Snippet 3, is that correct?
Below the instructions on how to implement that snippet, you’ll also find this: This snippet will likely need to be modified, because the Add to Cart variable in the snippet needs to match the class used on your site.
Open up one of your site’s product pages.
Right-click your "Add to Cart" button and select Inspect.
The console will open, showing the source code of your "Add to Cart" button. The following image shows the class of the "Add to Cart" button highlighted in the console.
Compare your button code in between the quotations, highlighted in the above example, with the contents in between the parentheses after getElementsByClassName in the code snippet above. For example, the class listed in the screenshot is btn product-form_cart-submit btn--secondary-accent and the variable listed in the snippet is add-to-cart.
If they don’t match, modify the snippet to match the class of your button. Our example’s modified snippet looks like this:
Perhaps installing Upcart changes the class name in your snippet, so you basically just have to repeat the whole process after switching it on, then trying again to see if it works.
By clicking “Accept All Cookies,” you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts.
Privacy Preference Center
Your Privacy
Strictly Necessary Cookies
Performance Cookies
Functional Cookies
Targeting Cookies
Site Analytics
Your Privacy
When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and change our default settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer.
Privacy Notice
Strictly Necessary Cookies
Always Active
These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.
Performance Cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. All information these cookies collect is aggregated and therefore anonymous. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.
Functional Cookies
These cookies enable the website to provide enhanced functionality and personalisation. They may be set by us or by third party providers whose services we have added to our pages. If you do not allow these cookies then some or all of these services may not function properly.
Targeting Cookies
These cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites. They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising.
Site Analytics
These cookies record your visit to our website, and are used to track your visit including information such as: web page interactions (clicks, hovers, focus, mouse movements, browsing, zooms and other interactions), referring web page/source through which you accessed the Sites, heatmaps and scrolls, screen resolution, ISP, and statistics associated with the interaction between device or browser and the Sites. If you are accessing our Services with a European IP address, you have been asked to consent to the use of these cookies (you are free to deny your consent).