Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

theUnforgiven's avatar

Cart Abandonment Script [JS]

Looking for help, advise or willing to pay someone £100 to do this, but here's what I'm after. To be exact I'm only looking for the javascript to be written to do this, rest I can deal with.

The script will need a unique reference number related to one site kind of like this:

var _cartstack = _cartstack || [];
_cartstack.push(['setSiteID', 'k49WWl5K']); /* unique ref number, which we will set via PHP */
_cartstack.push(['setAPI', 'tracking']); 
_cartstack.push(['setCartTotal', '']); 

This script then needs to be placed on any customer website that will then track uses of the site and any shopping cart abandonment that happens. This will also be set in our PHP application (we are using Laravel 5.1) but then we also need a script probably cURL or something to keep checking for this so the system will then know when a cart is abandoned.

If you take a look at www.cartstack.com you'll see the type of thing we need but not sure how to build the javascript or build the script to do the checks.

This kinda works like Google Analytics does, but it will be a case of showing a alert when the cart is abandoned then have the ability to send a SMS message, which I can do, it's just the javascript I need help with.

0 likes
8 replies
d3xt3r's avatar

Do you have the endpoints and the use case ready ?

theUnforgiven's avatar

No not yet I thought that would something I would do after the JS has been written.

It will just be a basic API returning JSON response that I can grab and use that data to then put into graphs and use the data then to send out SMS messages when a cart has been abandoned. This also needs to work across every platform like Magento, Wordpress, Volusion, Prestashop, Oscommerce which I believe will work when using JS anyhow.

d3xt3r's avatar

The javascript part is rather simple, IMO simple ajax calls will suffice to fetch/psuh the data, but, if you need to manipulate client's DOM elements then it might take some more work.

However, for it to work, CORS headers are must.

And given , its independent piece of code should work across platforms just like GA.

theUnforgiven's avatar

Is this something you can do?

Although I can read and understand most aspects of JS i find it hard to write it out I'm willing to pay £100 for this once I get it and it works to how the client needs it.

theUnforgiven's avatar

Cartstack offer the following if you wanted to take a look.

// Tracking Code
<script src="https://api.cartstack.com/js/cs.js" type="text/javascript"></script>
<script type="text/javascript">
  var _cartstack = _cartstack || [];
      _cartstack.push(['setSiteID', 'SITEID']); /* required */
      _cartstack.push(['setAPI', 'tracking']); /* required */
      _cartstack.push(['setCartTotal', '']); /* optional */
</script>

// Confirmation Code
<script type="text/javascript">
  var _cartstack = _cartstack || [];
      _cartstack.push(['setSiteID', 'SITEID']); /* required */
      _cartstack.push(['setAPI', 'confirmation']); /* required */
</script>
<script src="https://api.cartstack.com/js/cartstack.js" type="text/javascript"></script>

Perhaps take a look at - https://api.cartstack.com/js/cs.js & https://api.cartstack.com/js/cartstack.js

d3xt3r's avatar
d3xt3r
Best Answer
Level 29

Ya looked at, its pretty basic, let me know your requirements on mail though. Thanks

Please or to participate in this conversation.