Content block snippets can be used for many other purposes, such as adding analytics, affiliate, comparison, and social media tracking codes, or for simply adding simple site inclusions such as logos, wallpaper, and promotional messages to specific areas of the site. 

To use this tool, there needs to be an appreciation of the code and structure of the site(s) and channels being serviced.

It is advised that all changes should be carefully tested before they are applied to the live site, to avoid any detrimental impact on customer experience.

  1. Go to Storefront>Content Blocks
  2. Click New Content Block
  3. Select the folder
  4. Fill out the details as per your requirement for more details refer to the below table
    Snippet Information
    Snippet NameDisplay name of the snippet
    Content-TypeContent Blocks are made up of ‘Snippets’ of either JavaScript, HTML, or text.
    Snippet PlacementLocation of the snippet example head, footer, left panel of the site
    SnippetThe actual snippet code goes here
    Configuration
    Is ActiveEnable or disable a snippet
    Show Across SiteEnable if needed to be used across the site with an option to exclude some of the URLs
    Show On Specific PagesIf needed to be used on specific pages only
    Specific URLsPlace holder in case want to execute these snippets on specific URLs


  5. Click Save


Snippets list can be seen and filtered based on the below filters:

  1. Snippet Type: Javascript, Html, or Text
  2. Status:  Active or Inactive
  3. Dynamic Type:  Yes or No 
  4. Show Across Site: Yes or No



Snippets provide a valuable feature to the business, in so far as they enable you with an understanding of HTML, JavaScript, and Text files, to add in snippets of code to the site as needed.


A good example of where this could be useful is in the inclusion of Google Analytics tagging, where tags are required to be added within different locations e.g. Head or Body tags.


In the examples below, we explore some examples of how snippets can be used in practice.

     

 

Drilling down into the individual snippets you can see that we have two examples of how Google Analytics  (GA) can be applied to a site using a content block.

      

Configuration: The snipped of HTML code to be added to the entire site and applied across the (desktop, in-store, mobile, tablet, and web) site(s).

The code being added here is the account number for GA, which in this case is the same across all sites.


If you have a different GA Account per country then you would set up a snippet as above, but for each domain/site. The example above on the right is for the Order Confirmation Page and is therefore only applied to this specific page.  The JavaScript in this snippet is written to collect a set of data for GA from the order being taken, including the line-level detail of Product SKU, Unit Price, Line Quantity as well as the overall order value and delivery costs.


Note- BetterCommerce allows you to create multiple folders and move individual snippets to these folders as well