JavaScript Code Example

This example showcases a dark theme with Prism.js syntax highlighting and a "Copy code" button.

<script>
  function asylthe_getParam(p) {
    var match = RegExp('[?&]' + p + '=([^&]*)').exec(window.location.search);
    return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
  }

  try {
    var rv = asylthe_getParam('amt');
    var cm = asylthe_getParam('cm');
    var cc = asylthe_getParam('cc');

    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({
      'event': 'as_purchase',
      'orderID': cm,
      'conversionValue': parseFloat(rv),
      'currency': cc
    });
  } catch (err) {
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({
      'event': 'as_purchase_error'
    });
  }
</script>