How to add Google Analytics script in JIRA 6 ?

Alice Ark July 7, 2013

This page describes how to add Google Analytics in JIRA, but is not updated for JIRA 6 :

https://developer.atlassian.com/display/JIRADEV/Adding+JavaScript+to+all+pages+for+Google+Analytics

Can you tell us how to do it in JIRA 6 ?

4 answers

1 accepted

5 votes
Answer accepted
Claudio Ombrella November 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.

2 votes
Dipti Ranjan Behera
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 7, 2013

Hi Alice,

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

administration-->announcement banner.

Alice Ark July 7, 2013

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

Dipti Ranjan Behera
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 9, 2013

@Alice,

Did you tried it.

Alice Ark July 9, 2013

Hi,

Yes, and it works well !

Thank you

Alice

Dipti Ranjan Behera
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 9, 2013

@alice,

which solution did you tried , let me know.

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

AK April 15, 2014

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.

Teng Lee June 16, 2016

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?

Alice Ark June 16, 2016

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 June 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

Teng Lee June 19, 2016

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 June 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?

Teng Lee June 22, 2016

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?

WojciechS September 7, 2016

Check out my answer to get tracking on all pages: https://answers.atlassian.com/questions/187506

0 votes
WojciechS September 7, 2016

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;
0 votes
Dipti Ranjan Behera
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 7, 2013

@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 June 16, 2016

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

Suggest an answer

Log in or Sign up to answer