Placing the data layer
You do not need to add this code blocks to your theme manually. These are already added to your theme during the app installation. This info is here just for reference.
Index page
The code block below should be added to: templates/index.liquid
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <!-- Segmentify Script Block Start --> {% comment %} This script block added by Segmentify App. If you do not use the app you can remove the block. {% endcomment %} {% section 'segmentify-widget' %} <script type="text/javascript"> window.sgfLayer = { page: { pageUrl: "{{ shop.url }}", category: 'Home Page', referrer: document.referrer } } </script> <!-- Segmentify Script Block End --> |
Product page
The code block below should be added to: templates/product.liquid
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | <!-- Segmentify Script Block Start --> {% comment %} This script block added by Segmentify App. If you do not use the app you can remove the block. {% endcomment %} {%- assign current_variant = product.selected_or_first_available_variant -%} {% if cuurent_variant.image %} {%- assign image_src = current_variant.image.src -%} {% elsif product.featured_image %} {%- assign image_src = product.featured_image.src -%} {% elsif product.images[0] %} {%- assign image_src = product.images[0].src -%} {% else %} {%- assign image_src = "" -%} {% endif %} <script type="text/javascript"> window.sgfLayer = { page: { pageUrl: "{{ shop.url }}{{ product.url }}", category: 'Product Page', referrer: document.referrer, {% unless collection.title == blank %} subCategory: "{{collection.title}}" {% endunless %} }, product: { productId: "{{ current_variant.id }}", price: {{ current_variant.price | divided_by: 100.00}}, title: "{{ current_variant.title }}", categories: {{product.collections | map: 'title' | json }}, image: "{{ image_src | img_url: '300x300' }}", url: "{{ shop.url }}{{ product.url }}", brand: "{{ product.vendor }}", {% if current_variant.compare_at_price %}oldPrice: {{ current_variant.compare_at_price | divided_by: 100.00 }}, {% endif %} inStock: {% if product.available %}true{% else %}false{% endif %}, } }; </script> {{ current_variant.image.src }} {{ product.image[0].src }} {{ product.featured_image.src }} <!-- Segmentify Script Block End --> |
Cart page
The code block below should be added to: templates/cart.liquid
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | <!-- Segmentify Script Block Start --> {% comment %} This script block added by Segmentify App. If you do not use the app you can remove the block. {% endcomment %} {% section 'segmentify-widget' %} <script type="text/javascript"> cart_data = {{ cart | json}} window.sgfLayer = { page: { pageUrl: location.href, category: 'Basket Page', referrer: document.referrer }, checkout: { step: 'basket', basketId: cart_data.token, totalPrice: {{ cart.total_price | divided_by: 100.00}}, productList: cart_data.items.map(function(item){ return { productId: item.variant_id, quantity: item.quantity, price: parseFloat(item.price / 100.0) } }) } } </script> <!-- Segmentify Script Block End --> |
Collection page
The code block below should be added to: templates/collection.liquid
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <!-- Segmentify Script Block Start --> {% comment %} This script block added by Segmentify App. If you do not use the app you can remove the block. {% endcomment %} {% section 'segmentify-widget' %} <script type="text/javascript"> window.sgfLayer = { page: { pageUrl: "{{ shop.url }}{{ collection.url }}", category: 'Category Page', subCategory: "{{collection.title}}", referrer: document.referrer } } </script> <!-- Segmentify Script Block End --> |
Search page
The code block below should be added to: templates/search.liquid
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <!-- Segmentify Script Block Start --> {% comment %} This script block added by Segmentify App. If you do not use the app you can remove the block. {% endcomment %} {% section 'segmentify-widget' %} <script type="text/javascript"> window.sgfLayer = { page: { pageUrl: "{{ shop.url }}", category: 'Search Page', referrer: document.referrer } } </script> <!-- Segmentify Script Block End --> |
404 Page
The code block below should be added to: templates/404.liquid
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <!-- Segmentify Script Block Start --> {% comment %} This script block added by Segmentify App. If you do not use the app you can remove the block. {% endcomment %} {% section 'segmentify-widget' %} <script type="text/javascript"> window.sgfLayer = { page: { pageUrl: location.href, category: '404 Page', referrer: document.referrer } } </script> <!-- Segmentify Script Block End --> |