Sometimes, when it comes to analytics, you aren't always able to add code to the site, so you need to find other methods. You may also be trying to save costs, so conventional methods aren't always best. For this situation, we're looking at cart add and remove events.

For example, if we were using SiteCatalyst and wanted to normally check our cart add and remove events, we'd have to add a tracking call to every single button that does these functions. This has potential to do a high amount of click calls -- something that could mean paying much more to Adobe. One client reached out to me asking if there was a way to track these two events when the cart page loaded. They didn't have much ability to edit the code at that point, so tracking cart adds and removes had to be added differently. After some thinking, I came up with a solution that was pretty effective.

Description and Usage:

This plugin provides a way to track cart adds and removes in the event that you can't manually code it to a button like you typically would. This plugin will not work so well when there is a cart popup, but it works very well if every add to cart redirects to the cart page. Basically, this plugin will keep a cookie of current cart items (based on what appeared on the cart page load) and compare it with the items on the next load of the cart page. If they are different, it will fire the add or remove event as needed.

To use this plugin, add the code to your plugins section of your s_code. If you have adapted the code to work outside of SiteCatalyst, make sure the function is defined before you call it to set an event. After adding this plugin, add something like the following to your doPlugins:

if(document.URL.indexOf("Cart")){ = s.checkCartEvents('sc_cart_items',30);

The first statement says to ONLY fire the logic on the cart page. In theory, if you were tracking your cart popup, you may be able to add that into this condition. The second statement says to reset the cookie when you reach the confirmation page.

Get the code:

You can find the code through my code page here: