google analytics on confluence pages

srinivasp
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.
September 24, 2012

Can we gather analytics (via Google) on Confluence usage by pasting the javascript below into the page template header for any pages we want to track.

Can I do this within Confluence?

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-35048994-1']);
  _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>

7 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

8 votes
Answer accepted
Giuliano C_
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 25, 2012

Yes, you can perform it within Confluence. Please, refer to the following path:

Browse > Confluence Admin > 'Look and Feel' - Custom HTML > Edit

Through this page, insert your javascript where you want. In this case, at 'end of the HEAD'.

Kind Regards

srinivasp
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.
September 25, 2012

Interesting.. i will try this way.

Thanks, Srinivas

MarkC
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.
June 4, 2014

Does this need to have the AJS.toInit included before the function in the JavaScript to make it work in Confluence?

Joe Lindsay July 7, 2016

Does this work on a space level?

 

I am only interested in tracking the one space not all.

MarkC
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 8, 2016

You can apply it universally in Confluence, then within Analytics you can set up a view that shows only the analytics for a particular space by providing the URL.

Federico Olmus June 6, 2017

Thanks all!

  1. Does this apply to Confluence Cloud?
  2. Should this be done manually with all Confluence URLs that need to be tracked?

 

 

David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
June 6, 2017

@federico This is for Confluence Server only, where you can add custom JavaScript.

For Confluence Cloud, this is not possible, so you'll need to use an add-on such as:

Like Dave_Liao likes this
Federico Olmus June 13, 2017

I just downloaded your product, working fine so far! Thanks, David.

7 votes
Matthew J. Horn
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.
October 2, 2012
3 votes
BernardoA
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.
September 25, 2012

Also you can check this plugin:

https://marketplace.atlassian.com/plugins/me.davidsimpson.confluence.plugins.googleanalytics

This plugin displays reports for an external Confluence website, or a particular space...please check if this plugin suits for you.

srinivasp
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.
September 25, 2012

Yes. I already tried that. This requires a license though :)

1 vote
Vladimir Alexiev July 3, 2014

Hi! I want to do this only for one space. I go to Browse>Space Admin>Look and Feel>Themes>Configure theme>Messages>Header and enter the script there using the {html} macro (we're on conf 3.5).

However, Conf removes the leading bracket from <script>, and removes the closing tag </script> altogether. I even tried making a custom macro {html-script}, but the result is the same. Adding the script to an individual page works ok.

Please help!

1 vote
Adrien Ragot 2
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.
October 1, 2013

Go to:

  • Global Administration
  • Custom HTML
  • At the end of HEAD
  • Paste your script.

It works pretty well, I'm sure ;)

0 votes
Udhay Parerikkal May 25, 2014

All,

We have enabled google analytics and I would like to get metrics (page views and duration etc) on a specific confluence page and email to a particular user group.

Note: I'm not looking for a paid solution. The videos out there are old or specific to paid solution.

Thanks in advance

Udhay

David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
May 26, 2014
0 votes
Adrien Ragot 2
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.
September 29, 2013

Hi Srinivas, Please tick the right answer if it worked for you. Thanks!

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events