Sardius MediaSupport

Adding Google Analytics to your Channel

Updated

Overview

You can connect Google Analytics to your Sardius channel in one of two ways. Which one works for you depends on whether your channel supports a cookie banner, so start by checking that in Step 1.

MethodWhere you add itCookie banner needed?Best for
Google Analytics GA4 ID fieldChannel Settings > Social > Google Analytics GA4 IDYesChannels with cookie banner settings, especially those serving viewers in GDPR regions
Custom scriptChannel Settings > Social > Custom Head ContentNoChannels with custom layouts without cookie banner settings

Important: Use only one method per channel. Using both can block tracking or count visits twice.

Before You Begin

Make sure you have the following ready:

  • Access to the Sardius Control Panel at cp.sardius.media with permission to edit your channel's settings.
  • Your Google Analytics 4 Measurement ID (the ID that tells Google which property to send data to). It starts with G-, for example G-XXXXXXXXXX. You can find it in Google Analytics under Admin > Data Streams > select your web stream.
  • For Option 2 only: the full Google tag (gtag.js) script from that same Data Stream page, under View tag instructions > Install manually.

Cookie banner support decides which option will work for your channel, so check this first.

  1. Log into cp.sardius.media, go to Channels, and select your channel.

  2. In the left menu, click Customize Channel.

  3. Under your layout, click Features.

    Customize Channel page with the Features option highlighted under Default Experience

  4. Look for Cookie Banner Settings in the list.

    Cookie Banner Settings panel with Enable Banner switched on, button text fields, and color options

What you seeWhat it meansNext step
Cookie Banner Settings is in the listYour channel supports a cookie bannerSwitch on Enable Banner, click Update, then go to Option 1
No Cookie Banner SettingsYour channel's layout doesn't support a cookie bannerSkip to Option 2

Tip: While you're in Cookie Banner Settings, you can also change the button text (for example Accept and Only Use Necessary Cookies) and colors to match your brand. If your channel supports a banner but you'd rather not show one, you can still use Option 2.

With this method, Sardius handles Google Analytics for you. To respect viewer privacy (GDPR), Google Analytics only starts tracking after a viewer accepts the cookie banner on your channel.

  1. Log into cp.sardius.media.

  2. Go to Channels and select the channel you want to track.

  3. In the left menu, click Channel Settings, then select the Social tab.

    Sardius Control Panel left menu with Channel Settings highlighted under the Channel section

  4. Paste your Measurement ID (for example G-XXXXXXXXXX) into the Google Analytics GA4 ID field.

    Channel Settings Social tab with the Google Analytics GA4 ID field highlighted at the top

  5. Make sure the Custom Head Content box further down the same tab does not also contain a Google Analytics script. If it does, remove it.

  6. Scroll to the bottom of the page and click Update Channel.

Note: Make sure Enable Banner is switched on (see Step 1). Google Analytics only starts tracking after a viewer accepts the banner.

With this method, you manage the Google tag yourself. Tracking starts as soon as the page loads, with no cookie banner required. This is the right choice for custom layouts that don't include cookie banner settings.

  1. Log into cp.sardius.media.

  2. Go to Channels and select the channel you want to track.

  3. In the left menu, click Channel Settings, then select the Social tab.

    Sardius Control Panel left menu with Channel Settings highlighted under the Channel section

  4. Clear the Google Analytics GA4 ID field at the top of the tab. Leave it completely empty. If an ID is in this field, Sardius will hold tracking until cookies are accepted, which blocks your script too.

    Channel Settings Social tab with the Google Analytics GA4 ID field highlighted at the top

  5. Scroll down to Custom Head Content and paste your Google tag into the box. It should look like this, with your own Measurement ID in both places. The first line is long, so copy the whole block:

    <script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
      gtag('config', 'G-XXXXXXXXXX');
    </script>
    
  6. Click Preview to check that your channel still looks right. Invalid HTML in this box can break your channel.

  7. Click Update Channel below the box.

    Channel Settings Social tab with the Custom Head Content box highlighted and an arrow pointing to the Update Channel button

Note: You are responsible for your channel's privacy and cookie consent requirements when using this method. If you serve viewers in regions covered by GDPR, check with your legal or compliance team first.

Verify Tracking Is Working

  1. Open your channel in a new browser window. If you used Option 1, accept the cookie banner.
  2. In Google Analytics, go to Reports > Realtime.
  3. Within a minute or two, you should see at least one active user. That's you.

Tip: Changes can take some time to appear while your channel's cache clears. If nothing shows up right away, wait a little and try again in a private or incognito window.

Troubleshooting

What you seeLikely causeWhat to do
No data in Google Analytics, and your page source shows ga-disable-G-...An ID is in the Google Analytics GA4 ID field, but no viewer has accepted a cookie banner (or the channel has none)Use Option 2: clear the Google Analytics GA4 ID field and add the script to Custom Head Content
Visits look doubledBoth methods are active at the same timeKeep only one: either the ID field or the custom script
Still no data after clicking Update ChannelChannel cache hasn't cleared yetWait, then check again in a private window
Data still missing after all of the aboveSomething else is blocking the tagContact Sardius Support with your channel name and Measurement ID

Related articles