How to add Google Analytics script in JIRA 6 ?

4 answers

1 accepted

4 votes
Claudio Ombrella Community Champion Nov 19, 2013

The banner works well but it does not register all the hits, unfortunately. Example if you use the issue navigator and then click on the first issue, once you enter in the issue display this hit is recorded, but if you click on J or K (jump/back) this does not record a hit because the banner is not reloaded. We need to find a better way to include Google Analytics.

Hi Alice,

Why dont you add the google analytics script in 'announcement banner' configuration of jira, it will work.

administration-->announcement banner.

Hi,

Thank you for your quick answer !

I'd prefer to add the script inside <head> HTML tag, but if it works like this, it will be ok.

Alice

Hi,

Yes, and it works well !

Thank you

Alice

@alice,

which solution did you tried , let me know.

if mine is right , can you accept the answer :)

Adding the analytics code to the announcement banner works absolutely fine.

Just need to ensure that google analytics javascript URL is accessible from the server on which Jira is hosted.

Hi there, by Announcement Banner do you mean this?

Capture.PNG

Do I just paste the <script>.....</script> directly into the Announcement box?

I tried that it didn't work because the text that were pasted showed up directly in the Announcement Banner. 

Can you help?

Hi Teng,

It still works for me in JIRA 6, pasting the script in this field, like you described it. When you try to edit this field with HTML tags, is it working ? Like this one for exemple :

<span style="color:red">This is an important message</span>

Alice

Claudio Ombrella Community Champion Jun 16, 2016

Adding the Google script in the announcement banner is not enough. You will miss a lot of pages, for example if you search issues and you get let's say 10 results in the issue navigator, the banner will count on page hit when you load the first issue. If you then click on J (jump) or K (back) the screen is not loaded again so the banner does not run the Google Analytics script. The only way of solving this issue is by entering the Google Analytics script in the description of the summary field on each one of your field configurations you have, see screen shot below.

Screen Shot 2016-06-17 at 8.36.35 AM.png

Hi Claudio, I'm not sure that I fully understand your instructions.. When I put the <script>...</script> into the Description box, it appears on the screen underneath the Description field (which is how it should work when you put anything into that box), like this:

 Script.PNG

Am I missing something?

Claudio Ombrella Community Champion Jun 20, 2016

You need to enter the script in the description of the SUMMARY field not the description field. By the way which version of JIRA are you running?

I have inserted the script in the summary field now:

SUMMARYfield.PNG

The same thing has happened:

GAscript.PNG

I am on JIRA v7.

Any advice?

@alice,

I had done this earlier for jira 4.x version and it worked. And again, try to avoid doing any changes to installation files.

Claudio Ombrella Community Champion Jun 16, 2016

See may answer just posted above, using the banner is not enough.

As others have said, the trick is to use the announcement banner. The twist is that you also want to use the official autotrack plugin from Google, specifically the urlChangeTracker: https://github.com/googleanalytics/autotrack/blob/master/docs/plugins/url-change-tracker.md. It will enable tracking page views on single-page-app pages like issue navigator.

Example code that you would put in the announcement banner would be

&lt;!-- Library that allows to track SPA transitions (e.g. navigating issues) --&gt;
&lt;script type="text/javascript" src="
https://cdnjs.cloudflare.com/ajax/libs/autotrack/1.0.1/autotrack.js"&gt;&lt;/script&gt;

&lt;script type="text/javascript"&gt;
  (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-ACCOUNT_ID', 'auto');
  ga('send', 'pageview');
  // everything above is an official google analytics tracking code
  ga('require', 'urlChangeTracker'); // this makes sure transitions on
&lt;/script&gt;
&lt;style&gt;
/* add this only if the above code is the only thing in your announcement banner, this prevents ugly grey background and border added automatically if there is anything in the announcement banner */
#announcement-banner {
display: none;
}
&lt;/style&gt;

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,042 views 13 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot