Skip to content

Instantly share code, notes, and snippets.

@samnazari
Created May 30, 2017 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samnazari/4856a6eadcf8e9bf13a3ace2e7ae6cfd to your computer and use it in GitHub Desktop.
Save samnazari/4856a6eadcf8e9bf13a3ace2e7ae6cfd to your computer and use it in GitHub Desktop.
Sentient Ascend - Shopify Integration - Conversion Goal - Revenu
{% if first_time_accessed %}
<script type="text/javascript">
function createCookie(name, value, days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days*24*60*60*1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + value + expires + ";";
}
var cookieContent = "{{checkout.attributes.ascend}}";
createCookie('_ascend_index', '[%22_ascend_current%22]', 100);
createCookie('_ascend_current', cookieContent, 100);
</script>
<!-- ADD YOUR ASCEND.JS SNIPPET HERE!!--><script src="//media.ascend.ai/c/XXXXXXXXX-XXX/ascend.js"></script>
<script type="text/javascript">
var revenue = document.querySelector('.total-recap__final-price').textContent.slice(1);
var finalRevenue = parseFloat(revenue);
Ascend.Goals.trigger(finalRevenue); // track revenue
</script>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment