Custom scripts

Custom scripts let you add your own scripts, HTML, and CSS to every page of your Customer Portal and Storeganise website. You can use them to add a cookie consent banner, load Google Tag Manager after consent, add a chat widget or tracking pixel, or change how your pages look.Note: Custom code never runs in the Management Portal.

Adding a custom code

Only users with the Manager role can view or change custom scripts.
  1. Go to Main settings > Developer > Custom scripts & CSS
  2. Paste your code into the Head or End of body field.
  3. Click Save.
Your code is added to every page of your Customer Portal and website the next time each page loads. Every change is recorded in your account history, and all managers get an email saying who made the change.

Choosing the right field

Where you paste your code decides when it loads.
FieldWhere the code goesUse it for
HeadThe start of the page's <head>    , before anything else loadsCookie consent tools, consent defaults, Google Tag Manager, and anything that must run first
End of bodyJust before </body>    Chat widgets, pixels, custom styles, and anything that doesn't need to load first
Each field holds up to 10,000 characters.
In the EU and UK, tracking usually can't start until a visitor gives consent. Your consent tool, such as Cookiebot or Usercentrics, has to load before Google Tag Manager for this to work.
  1. Go to Main settings > Developer and clear the Google Tag Manager ID field. If this field is set, Storeganise loads Tag Manager itself and your consent tool can't control it.
  2. In the Head field, add your consent tool first and Google Tag Manager after it.
  3. Click Save.
  4. Follow your consent tool's own guide for any remaining setup, such as its consent template in Google Tag Manager.
This example uses Cookiebot with Google Consent Mode. Replace YOUR-COOKIEBOT-ID     and GTM-XXXXXXX     with your own IDs.
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('consent', 'default', {
    ad_storage: 'denied',
    ad_user_data: 'denied',
    ad_personalization: 'denied',
    analytics_storage: 'denied',
    wait_for_update: 500
  });
</script>
<script id="Cookiebot" src="https://consent.cookiebot.com/uc.js" data-cbid="YOUR-COOKIEBOT-ID" data-blockingmode="auto"></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-XXXXXXX');
</script>
Note: Other built-in integrations, such as Google Analytics and Segment, also load without waiting for consent. If you need consent for these, clear their fields in Settings > Developer and load them through custom scripts instead.

Changing the look with custom styles

Add CSS in the End of body field to change colors, fonts, and other details on your Customer Portal and website. Styles there load after Storeganise's own styles, so yours take priority. Styles in the Head field load first and are usually overridden.This example changes the brand color, uses a Google font, and rounds the buttons:
<style>
  @import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;700&display=swap');

  html:root {
    --brand: #0f766e;
    --brand-hover: #115e59;
    --brand-dark: #134e4a;
    --brand-dark-rgb: 19, 78, 74;
    --brand-light: #ccfbf1;
    --brand-text: #fff;
    --bs-body-font-family: 'DM Sans', sans-serif;
  }

  .btn {
    --bs-btn-border-radius: 999px;
  }
</style>
The --brand     colors come from your brand color in Settings. Changing them updates buttons, links, the header, and highlighted text everywhere at once. --brand-dark-rgb     is the same color as --brand-dark    , written as three numbers.
To load a stylesheet from another site, add a <link>     tag:
<link rel="stylesheet" href="https://cdn.example.com/my-styles.css">
Then add the stylesheet's domain, for example https://cdn.example.com    , to style-src     in the Custom CSP section of Main settings > Developer. If the stylesheet loads fonts from another domain, add that domain to font-src     too. Google Fonts is already allowed.

Tips for custom styles

  • Pages are built with Bootstrap 5, so most elements use standard class names such as .btn    , .card    , and .navbar    . Use your browser's developer tools to find the class of the element you want to change.
  • Page layouts and class names can change in Storeganise updates. Keep your styles small, and change the --brand     colors where you can instead of targeting individual elements.
  • Check your styles on the website and the Customer Portal, on both a phone and a computer.

Security rules for your code

Your Customer Portal and website use a Content Security Policy (CSP) to protect your customers. Most of this is handled for you, but some code works differently from a plain website:
  • Script and style tags work as normal. Every <script>     and <style>     tag in your code is trusted, along with any scripts those tags load.
  • Inline event handlers are blocked. Attributes such as onclick="..."     and javascript:     links don't run. Add event listeners from a <script>     tag instead.
  • Inline style="..."     attributes may be blocked. Use a <style>     tag with class names instead.
  • Connections to other domains must be allowed. If your code loads data, opens a chat connection, shows an iframe, or loads a stylesheet or font from another domain, add that domain to the Custom CSP section in Settings > Developer. This is usually under connect-src    , frame-src    , style-src    , or font-src    .
Only add code from sources you trust. Custom code runs on your customer-facing pages with the same access as Storeganise's own code.

Tracking page views in the Customer Portal

The Customer Portal is a single-page app. Your code runs once, when a visitor first opens it, and doesn't run again as they move between pages inside the portal.To track page views, use a trigger that listens for changes to the page address. In Google Tag Manager, this is the History Change trigger. Website pages are separate page loads, so your code runs on each one.

Troubleshooting

Use these checks when custom code doesn't behave as expected:
  • A page breaks after you add code: add ?nocustomscripts     to the end of the page address, for example https://yourdomain.com/account?nocustomscripts    . The page loads without your custom code, so you can confirm whether your code is the cause.
  • Your code doesn't seem to run: open your browser's developer console and look for errors. CSP errors name the blocked domain you need to allow.
  • Your change isn't showing: reload the page fully. Custom code is added when the page first loads, so moving between pages in the Customer Portal won't pick up a change.
Related articles
Customise your Content Security Policy
Google Tag Manager examples
Setting up Google Tag Manager (GTM)
Custom scripts