Skip to main content
Changes made to BigCommerce

See what scripts are applied to your store by the installation wizard.

Gareth Burroughes avatar
Written by Gareth Burroughes
Updated over 3 months ago

As part of the installation process, a number of scripts which power different Dotdigital features are applied automatically to your site. This article details those changes.

More recent installations of the BigCommerce integration for Dotdigital install the necessary scripts through the Dotdigital Tag.


Abandoned carts

To power the abandoned carts module we apply the following scripts:


Web behavior tracking

The Web behavior tracking script is inserted before the </head> tag of each site page.

var dm_insight_id ='uniqueID';
(function(w,d,u,t,o,c)
{w['dmtrackingobjectname']=o;c=d.createElement(t);c.async=1;
c.src=u;t=d.getElementsByTagName(t)
[0];t.parentNode.insertBefore(c,t);w[o]=w[o]||function()
{(w[o].q=w[o].q||[]).push(arguments);};w[o]('track');})
(window, document, '//static.trackedweb.net/js/_dmptv4.js',
'script', 'dmPt');

CartInsight

This script will be placed before the </body> tag of each page of your site.

// <<< Dotdigital Abandoned cart script >>>
var dmPt = dmPt ? dmPt : {};
// Change this value to true if you want to enable guest abandoned cart
dmPt.enableGuestAbandonedCart = false;
// Id or selector expression to return the newsletter sign up forms of your store
dmPt.newsletter_form_id="#ContactFooter";
!function(u){function e(t){var e,n,r,i=(e=t.target,n="input
[type=email]",(r=e.querySelector(n))&&r.value?
r.value:null);i&&a(i)}function a(t){n("dm-subscriber",t,365)}
function n(t,e,n){var r;e&&((r=new
Date).setTime(r.getTime()+24*n*60*60*1e3),u.cookie=t+"="+e+";
expires="+r.toGMTString()+"; path=/")}function t(t){for(var
e=t+"=",n=u.cookie.split(";"),r=0;r<n.length;r++){for(var i=n[r];"
"==i.charAt(0);)i=i.substring(1,i.length);if(0==i.indexOf(e))return
i.substring(e.length,i.length)}return null}dmPt&&
(dmPt.enableGuestAbandonedCart&&u.querySelectorAll(dmPt.
newsletter_form_id).forEach(function(t)
{t.addEventListener("submit",e,!1)}),dmPt.emailSubmitted=t("dm-
subscriber"),a(dmPt.emailSubmitted),dmPt.cartId=t("cart"),n("dm-
cart",dmPt.cartId,15))}(document);
{% if customer.email and customer.accepts_marketing %}
dmPt("identify", "{{ customer.email }}");
{% else %}
if(dmPt.enableGuestAbandonedCart && dmPt.emailSubmitted && dmPt.emailSubmitted !== ""){
dmPt("identify", dmPt.emailSubmitted);
}
{% endif %}
if(dmPt.cartId && dmPt.cartId !== ""){
dmPt("cartInsight", {
"programID": %programID%,
"cartDelay": %cartDelay%,
"cartID": dmPt.cartId, //This value is retrieved from a Shopify cookie
"cartPhase": "CUSTOMER_LOGIN",
"currency": "{{ shop.currency }}",
"subtotal": {{ cart.total_price }}/100,
"discountAmount": {{ cart.original_total_price | minus: cart.total_price }}/100,
"taxAmount": 0,
"grandTotal": {{ cart.total_price }}/100,
"cartUrl": "{{ shop.url }}/cart/{% for item in cart.items %}
{{item.variant_id}}:{{ item.quantity }}{% if forloop.last == false %}
,{% endif %}{% endfor %}",
"lineItems": [
{% for item in cart.items %}
{
"sku": "{{ item.sku }}",
"name": "{{ item.title }}",
"description": "{{ item.product.description | strip_html | escape |
strip_newlines }}",
"category": "{% for collection in item.product.collections %}{{
collection.title }} {% endfor %}",
"other": "{% for tag in product.tags %}{{ tag }} {% endfor %}",
"unitPrice": {{ item.original_price }}/100,
"salePrice": {{ item.price }}/100,
"quantity": {{ item.quantity }},
"totalPrice": {{ item.line_price }}/100,
"imageUrl": "{{ item.image | img_url: 'small' | prepend:'https:'}}",
"productUrl": "{{ shop.url }}{{ item.url}}",
} {% if forloop.last == false %},{% endif %}
{% endfor %}
]
});
}

Order success

This script is implemented on the Order Processing page of your site.

var dm_insight_id ='uniqueID';

(function(w,d,u,t,o,c)
{w['dmtrackingobjectname']=o;c=d.createElement(t);
c.async=1;c.src=u;t=d.getElementsByTagName
(t)[0];t.parentNode.insertBefore(c,t);w[o]=w[o]||function()
{(w[o].q=w[o].q||[]).push(arguments);};w[o]('track');
})(window, document, '//static.trackedweb.net/js/_dmptv4.js',
'script', 'dmPt');

// <<< Dotdigital Abandoned cart script >>>
var dmPt = dmPt ? dmPt : {};
// Change this value to true if you want to enable guest abandoned cart
dmPt.enableGuestAbandonedCart = false;

!function(i){function t(t){for(var
n=t+"=",r=i.cookie.split(";"),e=0;e<r.length;e++){for(var d=r[e];"
"==d.charAt(0);)d=d.substring(1);if(0==d.indexOf(n))return
d.substring(n.length,d.length)}return""}dmPt.enableGuestAbandonedCart&&
(dmPt.emailSubmitted=t("dm-subscriber")),dmPt.cartId=t("dm-cart")}
(document);

{% if customer.email and customer.accepts_marketing %}
dmPt("identify", "{{ customer.email }}");
{% else %}
if(dmPt.enableGuestAbandonedCart && dmPt.emailSubmitted && dmPt.emailSubmitted !== ""){
dmPt("identify", dmPt.emailSubmitted);
}
{% endif %}

if(dmPt.cartId && dmPt.cartId !== ""){
dmPt("cartInsight", {
"programID": %programID%,
"cartDelay": %cartDelay%,
"cartID": dmPt.cartId,
"cartPhase": "ORDER_COMPLETE",
"grandTotal": {{ total_price | money_without_currency }},
"currency": "{{ shop.currency }}",
"subtotal": {{ total_price | money_without_currency }},
"discountAmount": 0,
"taxAmount": 0,
"cartUrl": "{{ shop.url }}",
"lineItems": []
});
}

Chat

If you choose to install the Dotdigital Chat widget through the installation wizard, we apply the chat script to each page of your site.

<script>
window._ddgChatConfig = {
apiSpace: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
urlBase: 'https://webchat.dotdigital.com'

};
(function(d, s, id){
var js, cjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = 'https://webchat.dotdigital.com/widget/bootstrap.js';
cjs.parentNode.insertBefore(js, cjs);
}(document, 'script', 'ddg-chat-widget'));
</script>
Did this answer your question?