Skip to main content
Frank
Product Guru
May 31, 2018

Adding Third-party Scripts to Your Community (Google Analytics)

  • May 31, 2018
  • 23 replies
  • 2767 views

Do you want to empower your community with external services such as Google Analytics, Surveymonkey or Optimizely? Read on, because in this How To you’ll learn how to add these with the help of our Third-party Scripts feature.

 

How to add Third-party Scripts to your community

  1. Copy the code from a third-party that you want to add to the community.
  2. Administrators go to ControlCustomizationThird-party Scripts.
  3. Paste the code in the area where you want to add the code: in the <head> after the opening <body> or before the closing </body>
  4. Hit Save changes, and you’re done. The script is now injected globally, in all pages of your community.

 

Examples

How to add Google Analytics to your community

  1. Log in to Google Analytics and go to Admin
  2. In the column Account select an account
  3. In the column Property go to Tracking Info Tracking Code
  4. Copy the tracking code (gtag.js)
  5. Go to ControlCustomizationThird-party Scripts
  6. Paste the code in the <HEAD>area
  7. Hit Save changes, and you’re done. Google Analytics is now added to your community.


How to add Google Tag Manager to your community

  1. Log in to Google Tag Manager and click on your Container Name
  2. Click on the GTM Tracking ID (GTM-123ABC)
  3. Copy the tracking codes (2 codes)
  4. Go to Control CustomizationThird-party Scripts
  5. Paste the code in the < HEAD> area and after < BODY> area
  6. Hit Save changes, and you’re done. Google Tag Manager is now added to your community.

 

Supported services

  • Google Analytics
  • Google Tag Manager
  • Adobe Analytics
  • Atlassian Statuspage
  • Survey Monkey
  • Optimizely
  • Many more…

Note:

  • We recommend to test adding third-party scripts to your staging environment first, before adding scripts to your production community.
  • ​We recommend to add scripts before the closing tag. This way they will have the least impact on your community’s performance.
  • ​​​​​​We recommend inviting a professional web developer to help you add third-party scripts. Use any custom code at your own risk, and proceed with extreme caution — inSided support won’t be able to assist you with issues related to third-party scripts.

23 replies

timcavey
Helper ⭐️⭐️
June 16, 2022

@Julian following your intro and advice about GA4 at the first inSided EMEA Office Hours, I’ve not been able to get it any data from our instance. 

 

I’ve added it to our existing GTM as they instructed, alongside our existing GA Universal. Nothing. Have I just done it wrong or will it not display the data but it is collecting? 

 

 

learning, sharing and repeat
Julian
Gainsight Employee ⭐️⭐️⭐️
June 16, 2022

So I have just spent another half an hour in the rabbit hole that is GA4 to me, unfortunately without success. :( I also performed these steps and still do not see data. I currently see three reasons why this could be the case:

1. Our platform does not send the events that GA4 is looking for

This would require us to do changes in the platform to allow GA4 to measure like the universal GA is doing it. Here I actually performed a step which ensures that GA4 is using the same structure as the universal GA, but this did not seem to help.

2. The way that the GA4 tag is implemented is not sufficient

I did read that there are several ways to add the tag to the website. It could be that the way we are doing it (via Third-Party Scripts) is not supported and therefore the activation fails. What speaks for this theory is that I do not measure anything, what speaks against it is that GA usually indicates when a verification failed.​​​​​​

3. GA4 is requiring us to define segments / audiences before data can be surfaced

I have read several times that GA4 offers much more segmented insights into user behaviour (e.g. first visitor vs. logged in user), it could be that these segments need to be defined first before GA4 actually starts showing data.

I will have some conversations internally and also scour the internet for content that is more tailored to our context. Much of the official content is focussed on webshops / Apps, and this is far from what we are doing / are interested in.

I hope to be able to share more information with you soon!

I follow my nose, it always knows
timcavey
Helper ⭐️⭐️
June 20, 2022

Thanks @Julian!

 

To help me understand this:

 

2. The way that the GA4 tag is implemented is not sufficient

I did read that there are several ways to add the tag to the website. It could be that the way we are doing it (via Third-Party Scripts) is not supported and therefore the activation fails. What speaks for this theory is that I do not measure anything, what speaks against it is that GA usually indicates when a verification failed.​​​​​​

 

 They provide a step by step guide on adding the GA4 tag via GTM. If GTM is the third party script you refer to, surely these instructions suggest compatibility. 

 

We’re still using Universal so no real rush other than we miss out on GA4 data for this period when it’s next year and Universal is closed down.

 

Is the answer Mixpanel? 

learning, sharing and repeat
Contributor ⭐️⭐️⭐️
March 21, 2025

It looks like this is 6 years old. Do you have a instructions for the latest GA4, please?

Thanks! 

Liz K
alan.edwards
Contributor ⭐️⭐️⭐️
July 18, 2025

@Liz K you may have worked this out already, adding to future reference.

 

Go to the Third Party Scripts under settings:

Third Party Scripts setting

 Expand “INSERT IN <HEAD>” and paste in the code below

📌Add in your own ID by pasting over “[REPLACE WITH GA4 ID]” 

 

I also capture the UserID, Main Role and Custom Roles as user properties, feel free not to include.

<script async src="https://www.googletagmanager.com/gtag/js?id=[REPLACE WITH GA4 ID]"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '[REPLACE WITH GA4 ID]');

// Push an event listener into the dataLayer
window.dataLayer.push({
'event': 'setUserId', // Define a custom event name
'eventCallback': function() { // This function will be called when the event is triggered
if (window.userId) {
gtag('set', 'user_properties', {
community_user_id: window.userId,
role: window.inSidedData.user.role,
MainRole: window.inSidedData.user.mainRole
});
gtag('set', {
user_id: window.userId
});
}
}
});
</script>

End result:

GTM Debug tool

 

Contributor ⭐️⭐️⭐️
July 24, 2025

@Liz K you may have worked this out already, adding to future reference.

 

Go to the Third Party Scripts under settings:

 Expand “INSERT IN <HEAD>” and paste in the code below

📌Add in your own ID by pasting over “[REPLACE WITH GA4 ID]” 

 

I also capture the UserID, Main Role and Custom Roles as user properties, feel free not to include.

<script async src="https://www.googletagmanager.com/gtag/js?id=[REPLACE WITH GA4 ID]"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '[REPLACE WITH GA4 ID]');

// Push an event listener into the dataLayer
window.dataLayer.push({
'event': 'setUserId', // Define a custom event name
'eventCallback': function() { // This function will be called when the event is triggered
if (window.userId) {
gtag('set', 'user_properties', {
community_user_id: window.userId,
role: window.inSidedData.user.role,
MainRole: window.inSidedData.user.mainRole
});
gtag('set', {
user_id: window.userId
});
}
}
});
</script>

End result:

GTM Debug tool

 

Thanks ​@alan.edwards does this mean that I only need to enter my Stream ID in both places and not my Measurement ID or the other way round? 


And for the End result section, do I put that API call info in there or…?

Thanks!

Liz K
alan.edwards
Contributor ⭐️⭐️⭐️
July 24, 2025

Add in your Measurement ID.

 

You do not need to add the “End result:” this the Google Tag Assistant screenshot if you debug your site, it shows the data is flowing.

 

jvdc
Expert ⭐️
July 29, 2025

Do you know if there would be a way to send in the data layer the Session ID that Gainsight generates ?

I am trying to link the Gainsight session ID to searched terms pulled from GA4

revathimenon
Gainsight Community Manager
July 31, 2025

Hey ​@jvdc 

Looks like you're already working with the support team on this, so I’ll go ahead and close the loop here for now. Feel free to bump this thread anytime if you get stuck. 🙌🏼

 

Where focus goes, energy flows.
jvdc
Expert ⭐️
August 18, 2025

Hey ​@alan.edwards , I have implemented something similar as you, where I am catching the user ID.

Is GA4 systematically catching those IDs? In my case, it seems to be caught only 50% of the times, the rest I am getting a “(not set)”…

Did you do anything else in GTM?

I assume you created dimensions in GA4 for those value, right?