Data Layer Script to be Removed from Checkout Settings

When upgrading to the new Shopify Source reference this for an example of the data layer script you may need to remove

The script in your checkout settings will contain your GTM ID and may be different than the code below based on the last data layer version you've installed, however you'll find the code begins with the Elevar Data Layer comment and ends with the Google Tag Manager comment.

<!--
Elevar Data Layer

This file is automatically updated and should not be edited directly.

https://knowledge.getelevar.com/how-to-customize-data-layer-version-2

Version: 3.8.3
-->
<!-- Google Tag Manager -->
<script>
  window.dataLayer = window.dataLayer || [];
</script>
<script>
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({"gtm.start":
  new Date().getTime(),event:"gtm.js"});var f=d.getElementsByTagName(s)[0],
  j=d.createElement(s),dl=l!="dataLayer"?"&l="+l:"";j.async=true;j.src=
  "https://www.googletagmanager.com/gtm.js?id="+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,"script","dataLayer","GTM-OOOOOO");
</script>
<!-- End Google Tag Manager -->
<script id="elevar-gtm-suite-config" type="application/json">{"gtm_id": "GTM-OOOOOO", "apex_domain": "website.com", "event_config": {"user": true, "cart_view": true, "product_view": true, "checkout_step": true, "cart_reconcile": true, "product_select": true, "collection_view": true, "save_order_notes": false, "checkout_complete": true, "product_add_to_cart": false, "search_results_view": true, "product_add_to_cart_ajax": true, "product_remove_from_cart": true, "defers_collection_loading": false, "defers_search_results_loading": false}, "consent_enabled": true, "gtm_suite_script": "https://shopify-gtm-suite.getelevar.com/shops/7ddbe4b9dd7d0bc7a28f4a47c8ea7c0dced000000/3.8.3/gtm-suite.js"}</script>

<script>
  (() => {
    if (!window.__ElevarIsGtmSuiteCalled) {
      window.__ElevarIsGtmSuiteCalled = true;
      const init = () => {
  window.__ElevarDataLayerQueue = [];
  window.__ElevarListenerQueue = [];
  if (!window.dataLayer) window.dataLayer = [];
};
      init();
      window.__ElevarTransformItem = event => {
  if (typeof window.ElevarTransformFn === "function") {
    try {
      const result = window.ElevarTransformFn(event);
      if (typeof result === "object" && !Array.isArray(result) && result !== null) {
        return result;
      } else {
        console.error("Elevar Data Layer: `window.ElevarTransformFn` returned a value " + "that wasn't an object, so we've treated things as if this " + "function wasn't defined.");
        return event;
      }
    } catch (error) {
      console.error("Elevar Data Layer: `window.ElevarTransformFn` threw an error, so " + "we've treated things as if this function wasn't defined. The " + "exact error is shown below.");
      console.error(error);
      return event;
    }
  } else {
    return event;
  }
};
      window.ElevarPushToDataLayer = item => {
  const date = new Date();
  localStorage.setItem("___ELEVAR_GTM_SUITE--lastDlPushTimestamp", String(Math.floor(date.getTime() / 1000)));
  const enrichedItem = {
    event_id: window.crypto.randomUUID ? window.crypto.randomUUID() : String(Math.random()).replace("0.", ""),
    event_time: date.toISOString(),
    ...item
  };
  const transformedEnrichedItem = window.__ElevarTransformItem ? window.__ElevarTransformItem(enrichedItem) : enrichedItem;
  const payload = {
    raw: enrichedItem,
    transformed: transformedEnrichedItem
  };
  if (transformedEnrichedItem._elevar_internal?.isElevarContextPush) {
    window.__ElevarIsContextSet = true;
    window.__ElevarDataLayerQueue.unshift(payload);
    window.__ElevarListenerQueue.unshift(payload);
  } else {
    window.__ElevarDataLayerQueue.push(payload);
    window.__ElevarListenerQueue.push(payload);
  }
  window.dispatchEvent(new CustomEvent("elevar-listener-notify"));
  if (window.__ElevarIsContextSet) {
    while (window.__ElevarDataLayerQueue.length > 0) {
      const event = window.__ElevarDataLayerQueue.shift().transformed;
      window.dataLayer.push(event);
    }
  }
};

      const configElement = document.getElementById("elevar-gtm-suite-config");

      if (!configElement) {
        console.error("Elevar: DL Config element not found");
        return;
      }

      const config = JSON.parse(configElement.textContent);

      const script = document.createElement("script");
      script.type = "text/javascript";
      script.src = config.gtm_suite_script;
      script.async = false;
      script.defer = true;

      script.onerror = () => {
        console.error("Elevar: DL JS script failed to load");
      };
      script.onload = async () => {
        if (!window.ElevarGtmSuite) {
          console.error("Elevar: `ElevarGtmSuite` is not defined");
          return;
        }

        window.ElevarGtmSuite.utils.emailCapture();

        const cartData = {
  attributes: {{- cart.attributes | json -}},
  cartTotal: "{{- cart.total_price | times: 0.01 | json -}}",
  currencyCode: {{- cart.currency.iso_code | json -}},
  items: [
    {%- for line_item in cart.items -%}
      {
        {%- if line_item.sku != blank -%}
          id: {{- line_item.sku | json -}},
        {%- else -%}
          id: "{{- line_item.product_id | json -}}",
        {%- endif -%}
        name: {{- line_item.product.title | json -}},
        brand: {{- line_item.vendor | json -}},
        category: {{- line_item.product.type | json -}},
        variant: {{- line_item.variant.title | json -}},
        price: "{{- line_item.final_price | times: 0.01 | json -}}",
        position: {{- forloop.index -}},
        quantity: "{{- line_item.quantity | json -}}",
        productId: "{{- line_item.product_id | json -}}",
        variantId: "{{- line_item.variant_id -}}",
        compareAtPrice: "{{- line_item.variant.compare_at_price | times: 0.01 | json -}}",
        image: "{{- line_item.image | image_url -}}"
      },
    {%- endfor -%}
  ]
}
;

        await window.ElevarGtmSuite.handlers.cartAttributesReconcile(
          cartData,
          config.event_config.save_order_notes,
          config.consent_enabled,
          config.apex_domain
        );

        if (config.event_config.user) {
          const data = {
  {%- if checkout -%}
    cartTotal: "{{- checkout.total_price | times: 0.01 | json -}}",
    currencyCode: {{- checkout.currency | json -}},
  {%- else -%}
    cartTotal: "{{- cart.total_price | times: 0.01 | json -}}",
    currencyCode: {{- cart.currency.iso_code | json -}},
  {%- endif -%}
  {%- if customer -%}
    customer: {
      id: "{{- customer.id | json -}}",
      email: {{- customer.email | json -}},
      firstName: {{- customer.first_name | json -}},
      lastName: {{- customer.last_name | json -}},
      phone: {{- customer.phone | json -}},
      city: {{- customer.default_address.city | json -}},
      zip: {{- customer.default_address.zip | json -}},
      address1: {{- customer.default_address.address1 | json -}},
      address2: {{- customer.default_address.address2 | json -}},
      country: {{- customer.default_address.country | json -}},
      countryCode: {{- customer.default_address.country_code | json -}},
      province: {{- customer.default_address.province | json -}},
      provinceCode: {{- customer.default_address.province_code | json -}},
      tags: {{- customer.tags | join: ', ' | json -}}
    }
  {%- endif -%}
};
          window.ElevarGtmSuite.handlers.user(data);
        }

        {%- if first_time_accessed -%}
        if (config.event_config.checkout_complete) {
          const data = {%- if checkout -%}
  {
    currencyCode: {{- checkout.currency | json -}},
    actionField: {
      {%- if checkout.order_id -%}
        id: {{- checkout.order_id | json -}},
      {%- else -%}
        id: {{- checkout.id | json -}},
      {%- endif -%}
      {%- if checkout.order_name -%}
        order_name: {{- checkout.order_name | json -}},
      {%- endif -%}
      affiliation: {{- shop.name | json -}},
      revenue: "{{- checkout.total_price | times: 0.01 | json -}}",
      tax: "{{- checkout.tax_price | times: 0.01 | json -}}",
      shipping: "{{- checkout.shipping_price | times: 0.01 | json -}}",
      {%- if checkout.discount_applications -%}
        coupon: {{- checkout.discount_applications[0].title | json -}},
      {%- endif -%}
      {%- if order.subtotal_price -%}
        subTotal: "{{- order.subtotal_price | times: 0.01 | json -}}",
      {%- elsif checkout.subtotal_price -%}
        subTotal: "{{- checkout.subtotal_price | times: 0.01 | json -}}",
      {%- endif -%}
      productSubTotal: "{{- checkout.line_items_subtotal_price | times: 0.01 | json -}}",
      discountAmount: "{{- checkout.discounts_amount | times: 0.01 | json -}}"
    },
    {%- if checkout.customer -%}
      customer: {
        id: "{{- checkout.customer.id | json -}}",
        email: {{- checkout.email | json -}},
        firstName: {{- checkout.billing_address.first_name | json -}},
        lastName: {{- checkout.billing_address.last_name | json -}},
        {%- if checkout.customer.phone -%}
          phone: {{- checkout.customer.phone | json -}},
        {%- elsif checkout.billing_address.phone -%}
          phone: {{- checkout.billing_address.phone | json -}},
        {%- else -%}
          phone: {{- checkout.shipping_address.phone | json -}},
        {%- endif -%}
        city: {{- checkout.billing_address.city | json -}},
        zip: {{- checkout.billing_address.zip | json -}},
        address1: {{- checkout.billing_address.address1 | json -}},
        address2: {{- checkout.billing_address.address2 | json -}},
        country: {{- checkout.billing_address.country | json -}},
        countryCode: {{- checkout.billing_address.country_code | json -}},
        province: {{- checkout.billing_address.province | json -}},
        provinceCode: {{- checkout.billing_address.province_code | json -}},
        tags: {{- checkout.customer.tags | json -}}
      },
    {%- endif -%}
    items: [
      {%- for line_item in checkout.line_items -%}
        {
          {%- if line_item.sku != blank -%}
            id: {{- line_item.sku | json -}},
          {%- else -%}
            id: "{{- line_item.product_id | json -}}",
          {%- endif -%}
          name: {{- line_item.product.title | json -}},
          brand: {{- line_item.vendor | json -}},
          category: {{- line_item.product.type | json -}},
          variant: {{- line_item.variant.title | json -}},
          price: "{{- line_item.final_price | times: 0.01 | json -}}",
          quantity: "{{- line_item.quantity | json -}}",
          productId: "{{- line_item.product_id | json -}}",
          variantId: "{{- line_item.variant_id -}}",
          image: "{{- line_item.image | image_url -}}"
        },
      {%- endfor -%}
    ],
    landingSite: {{- checkout.landing_site | json -}}
  }
{%- endif -%}
;
          window.ElevarGtmSuite.handlers.checkoutComplete(data);
        }
        {%- endif -%}
      };

      document.head.appendChild(script);
    }
  })();
</script>

<!-- Google Tag Manager (noscript) -->
<noscript>
    <iframe src="https://www.googletagmanager.com/ns.html?id=GTM-OOOOOO" height="0" width="0" style="display:none;visibility:hidden"></iframe>
</noscript>
<!-- End Google Tag Manager (noscript) -->