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

tomasmouton
Contributor ⭐️⭐️⭐️⭐️
June 4, 2018
Hi 😃

This seems a very nice development! I went to Control but I have no such Tab "System Configuration" 🤔

Can you help? Do you need to enable it?
Regards, Tomás Mouton
Frank
FrankAuthor
Product Guru
June 4, 2018
Hey Tomas,

This is only available for branded clients, as on a custom community you've always been able to add custom scripts by submitting a request to the support desk, while up until this point, branded clients could not have any custom scripts unless it was included in their SSI.
😌
OVOdarran
Helper ⭐️
December 4, 2018
Glad we have this, however, having received the code/script from our Dev team, I have pasted it into the Before section but its not showing?

Anyone have any ideas?? The dev team are pretty sure the code base is correct. Am I putting it in the wrong place??

@Julian @Maryam

Darran
Community Manager // OVO Energy / Boost Power
Julian
Gainsight Employee ⭐️⭐️⭐️
December 4, 2018
Hey Darran!

Well some code is supposed to remain hidden. 😃 I could have a look, however as I am not good at coding, I would recommend our mate @tom.shaddock. He probably will find the issue in no-time, I hope he has the time to check it.

Cheers,

Julian
I follow my nose, it always knows
tom.shaddock
Gainsight Employee ⭐️⭐️
December 4, 2018
Hey @OVOdarran, I've had a look at your code - it looks as if its been copied and pasted in wrong 🙂. Basically I can see the end of the code doesn't look quite right:

.footer .col-social-med...

That's the last CSS rule in your pasted in code, it looks like the rest of it was truncated for whatever reason and then an ellipsis (...) added in place of the missing code.

Are you able to send me the entire original script via email? I can take a look at it and am happy to apply it to your community if you wanted.

Tom
OVOdarran
Helper ⭐️
December 5, 2018
Hey @tom.shaddock we've worked it out and its now live! Thank god for Dev's!! lol
Community Manager // OVO Energy / Boost Power
tom.shaddock
Gainsight Employee ⭐️⭐️
December 5, 2018
Hey @OVOdarran glad its working! 😃
timcavey
Helper ⭐️⭐️
March 17, 2021

Has anyone here used this for Optimizely? 

 

Am I right in thinking this script is meant to make small changes to the page display? 

 

In another related question, is it possible to add two Google Analytics scripts?

learning, sharing and repeat
Blastoise186
Helper ⭐️⭐️⭐️
March 17, 2021

Howdy!

You can indeed have multiple Google Analytics tags active if you wish @timcavey , but only with the new script - the legacy one will break if you try this. So…

:negative_squared_cross_mark: Don’t try it with this one!

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

:white_check_mark: Do try it with this one!

<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXXX-Y', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->

As for Optimizely, I’ve heard of it and it does indeed do what you think it does. However, it’s worth bearing in mind that we’ve got a mixture of content at play and even to this day, there’s still a few members who use BBCode formatting despite the new editor not officially supporting it - along with some other more complicated non-standard stuff. There is a risk that using Optimizely could break some of those things.As it’s a pretty powerful script, you’ll want to use it carefully too.

The other thing to watch out for, is that inSided changes things on a very rapid basis. Presumably tools like that can handle agile development flows from upstream, but be prepared to turn it off should something go bang. If it’s breaking things really badly, you’ll probably want to shut it down for a while.

Mind you… When I look at the details… I get the feeling it might work better as a direct integration between inSided and Optimizely, or as a native feature within inSided itself.

There is a bit of a Gotcha! however. In my personal experience with my somewhat slow internet connection, Optimizely has historically caused me quite a few headaches when it wasn’t configured properly.

I’ve also run some analysis, done a bit of research and had a think about this next one. As far as I can tell, inSided is very heavily cached for both Static and Dynamic content. While Optimizely can handle Static Caching, it’s not very good with handling Dynamic Caching, which may either prevent the script from working properly, or potentially completely break stuff.

I think it’s probably worth seeing if @tom.shaddock has any thoughts though. Having seen what Optimizely can do when it works well, I’d be curious to see if work with inSided - but only if it won’t break everything!

Bug blasting absolutely everything... The Blastoise Way
timcavey
Helper ⭐️⭐️
March 18, 2021

Thanks @Blastoise186 

 

Howdy!

You can indeed have multiple Google Analytics tags active if you wish @timcavey , but only with the new script - the legacy one will break if you try this. So…

:negative_squared_cross_mark: Don’t try it with this one!

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

:white_check_mark: Do try it with this one!

<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXXX-Y', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->

 

 

I can see that Google Tags Manager is a third-party script we have, not GA. Which tells me it’s in GTM that I need to add the second GA tags. @Kenneth R anyone over there have the keys to this?

 

 

I get the feeling it might work better as a direct integration between inSided and Optimizely, or as a native feature within inSided itself.

 

 

@Frank what do we think about this? It’s listed as a supported service in the main topic...

 

I think it’s probably worth seeing if @tom.shaddock has any thoughts though. Having seen what Optimizely can do when it works well, I’d be curious to see if work with inSided - but only if it won’t break everything!

 

Yes please Tom! 

learning, sharing and repeat