The following are some key things to note about the Shopping cart view Javascript event:
- Nearly the same as "Add to Cart" above, but instead of firing just one 'addItem' push you loop through a collection of items and track each one.
- Fire the event when a person lands on their full shopping cart view page.
- Or if you have an AJAX cart icon on the site that displays the full cart.
Shopping cart view
The shopping cart view event will need to include all the items that are in the shopping cart. The easiest way to accomplish this is to use a loop to push all the items.
- The
for(condition)
loop should iterate through all the items in the shopping cart.
/*** EVENT SPECIFIC CODE ***/
_rsq.push(['_addItem', {
'id':'item_id', // replace item_id with your dynamic item_id variable
'name':'item_title', // replace item_title with your dynamic item_title variable
'price':'item_price'// replace item_price with your dynamic item_price variable
}]);
_rsq.push(['_setAction', 'shopping_cart']);
/*** END EVENT SPECIFIC CODE ***/
Shopping cart view code sample
<!-- RetentionScience start -->
<script type='text/javascript'>
var _rsq = _rsq || [];
_rsq.push(['_setSiteId', 'site_id']); // replace site_id with your static Site ID
_rsq.push(['_enableOnsite']);
if (condition) { // replace condition with your parameters for checking if a user is logged in
_rsq.push(['_setUserId', 'user_id']); // replace user_id with your dynamic user_id variable
_rsq.push(['_setUserEmail','user_email']); // replace user_email with your dynamic user_email variable
}
/*** EVENT SPECIFIC CODE ***/
_rsq.push(['_addItem', {
'id':'item_id', // replace item_id with your dynamic item_id variable
'name':"item_title", // replace item_title with your dynamic item_title variable
'price':'item_price'// replace item_price with your dynamic item_price variable
}]);
_rsq.push(['_setAction', 'shopping_cart']);
/*** END EVENT SPECIFIC CODE ***/
_rsq.push(['_track']);
(function() {
var rScix = document.createElement('script');
rScix.type = 'text/javascript';
rScix.async = true;
rScix.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'd1stxfv94hrhia.cloudfront.net/waves/v3/w.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(rScix);
})();
</script>
<!-- RetentionScience end -->
Shopping cart view event data sample
Comments
0 comments
Please sign in to leave a comment.