Logo

Add tracker to Order status page

How to add SlideRule's GTM tracker code to your Shopify store's order status page.

To install Google Tag Manager and track purchases you need to add the below tracking code to the Orders status page.

Order status page tracking code

Make sure to replace GTM-XXXXX with your Google Tag Manager contianer id.

<script name="sliderule-tracking" data-ot-ignore>
  (function(){
  	slideruleData = {
      "version":"v0.0.2",
      "ecommerce":{"currencyCode":"{{shop.currency}}","impressions":[]},
      "pageType":"checkout",
  	"destinations":{
          "google_tag_manager": {
    			"containerIds": ["GTM-XXXXX"]
    		}
  	},
  	}

  	{% if content_for_header contains "previewBarInjector.init();" %}
  		slideruleData.themeMode = "preview"
  	{% elsif content_for_header contains "Shopify.designMode" %}
  		slideruleData.themeMode = "design"
  	{% else %}
  		slideruleData.themeMode = "live"
  	{% endif %}


      slideruleData.pageType = "confirmation";
      {% if post_purchase_page_accessed %}
          slideruleData.pageType = "confirmation";
      {% elsif first_time_accessed %}
      slideruleData.pageType = "purchase";
      {% endif %}

      slideruleData.shopifyLiquidData = {}
      slideruleData.shopifyLiquidData.checkout = {
          {%- if checkout.order_name -%}
          order_name: {{- checkout.order_name | json -}},
          {%- endif -%}
          {%- if checkout.order_name -%}
          order_number: {{- checkout.order_number | json -}},
          {%- endif -%}
      }

      {% if customer %}
          slideruleData.shopifyLiquidData.customer = {
              "accepts_marketing": {{- customer.accepts_marketing | json -}},
              "addresses": {{- customer.addresses | json -}},
              "addresses_count": {{- customer.addresses_count | json -}},
              "b2b?": {{- customer."b2b?" | json -}},
              "company_available_locations": {{- customer.company_available_locations | json -}},
              "current_company": {{- customer.current_company | json -}},
              "current_location": {{- customer.current_location | json -}},
              "default_address": {
                  "address1": {{ customer.default_address.address1 | json }},
                  "address2": {{ customer.default_address.address2 | json }},
                  "city": {{ customer.default_address.city | 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 -}},
                  "zip": {{ customer.default_address.zip | json }}
              },
              "email": {{ customer.email | json }},
              "first_name": {{ customer.first_name | json }},
              "has_account": {{- customer.has_account | json -}},
              "id": {{ customer.id | json }},
              "last_name": {{ customer.last_name | json }},
              "last_order": {{- customer.last_order | json -}},
              "name": {{ customer.name | json }},
              "orders_count": {{ customer.orders_count | json }},
              "phone": {{ customer.phone | json }},
              "tags": {{- customer.tags | join: ', ' | json -}},
              "tax_exempt": {{- customer.tax_exempt | json -}},
              "total_spent": {{ customer.total_spent | json }},
          }
      {% elsif checkout.customer %}
          slideruleData.shopifyLiquidData.customer = {
              "accepts_marketing": {{- customer.accepts_marketing | json -}},
              "addresses": {{- customer.addresses | json -}},
              "addresses_count": {{- customer.addresses_count | json -}},
              "b2b?": {{- customer."b2b?" | json -}},
              "company_available_locations": {{- customer.company_available_locations | json -}},
              "current_company": {{- customer.current_company | json -}},
              "current_location": {{- customer.current_location | json -}},
              "default_address": {
                  "address1": {{ customer.default_address.address1 | json }},
                  "address2": {{ customer.default_address.address2 | json }},
                  "city": {{ customer.default_address.city | 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 -}},
                  "zip": {{ customer.default_address.zip | json }}
              },
              "email": {{ customer.email | json }},
              "first_name": {{ customer.first_name | json }},
              "has_account": {{- customer.has_account | json -}},
              "id": {{ customer.id | json }},
              "last_name": {{ customer.last_name | json }},
              "last_order": {{- customer.last_order | json -}},
              "name": {{ customer.name | json }},
              "orders_count": {{ customer.orders_count | json }},
              "phone": {{ customer.phone | json }},
              "tags": {{- customer.tags | join: ', ' | json -}},
              "tax_exempt": {{- customer.tax_exempt | json -}},
              "total_spent": {{ customer.total_spent | json }},
          }
      {%- endif -%}
      })();
</script>
<script
  async
  type="text/javascript"
  src="https://grow.slideruleanalytics.com/eluredils-g.js"
></script>