Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Confluence analytics, individual space stats & Piwik

I would like to colect user access statistics and Piwik ( seems to do it well.

Howevwer - I have a Q on what would be the best approach/setup for tracking individual space stats.

  • my url:
  • some TEAMs would like to have stats of their own spaces
  • i'd like to collect global stats as well

should I go with

  • 1 global javascript blob in "custom HTML" - for global stats
  • define new sites in Piwik per space and insert their unique javascript blobs into respective spaces (Documentation theme)?
  • or rather use "Goals" in Piwik to track visits for urls containing "/confluence/display/MYTEAM"

I am loooking for a combination of a performance/ease of use/flexibility features.

thanks in advance

related questions:

2 answers

1 accepted

4 votes
Answer accepted

Adding custom JavaScript to each space individually sounds like madness. Use the same "blob" throughout (yes, put it in the Custom HTML section), but use some kind of custom variables to differentiate the individual spaces.

This means that you can view analytics site-wide, but also just for individual spaces.

Here's how we do things for the Webtrends and Google Analytics plugins:

if (typeof AJS.params.spaceKey == 'string'){

	// Webtrends 
	dcsMultiTrack('DCSext.w_space_key', AJS.params.spaceKey);
	// Google Analytics
		1,                       // This custom var is set to slot #1 of 5
		'confluence-space-key',  // The name acts as a kind of category for the activity
		AJS.params.spaceKey,     // This value of the custom variable
		3                        // Sets the scope to page-level

Once this is set up, you'd need to construct a custom report to filter on the w_space_key custom dimension (Webtrends) or confluence-space-key custom variable (Google Analytics)

Looking at the Piwik wiki it seems that the JavaScript is almost directly lifted from the pre-async Google Analytics days:

piwikTracker.setCustomVariable(1, 'confluence-space-key', AJS.params.spaceKey, 'page');

You just need to build the custom reports :)

-- Hope this helps, David

P.S. I'm also curious why you want to use Piwik over Google Analytics.

P.P.S. If you need further help, AppFusions have expertise in integrating Confluence with solutions from various web analytics vendors.

we run CONF in an enterprise environment and dealing with IT Security department questioning "why do we send data to GOOG" would be too risky, i guess :)

@webwesen: How did this go? Was it helpful? If so, give it an up-vote/mark as correct ;-)

You wouldn't happen to have screenshots on what that filter would look like in Google Analytics would you? I'm having trouble creating the Custom Report.

I had a similar need to track Confluence with Piwik, including custom variables.  We inserted the following code into Confluence's head (see Confluence how to article):

<!-- Piwik -->
<script type="text/javascript">
	var _paq = _paq || [];

		var u = (("https:" == document.location.protocol) ? "https://<<INSERT YOUR PIWIK URL HERE>>" : "http://<<AND HERE>>");
		_paq.push(['setSiteId', <<INSERT YOUR ID HERE>>>]);
		_paq.push(['setTrackerUrl', u+'piwik.php']);
		_paq.push(['setCustomVariable', 1, "Space", AJS.params.spaceKey, "visit"]);
		_paq.push(['setCustomVariable', 2, "NTid", AJS.params.remoteUser, "visit"]);
		_paq.push(['setCustomVariable', 3, "User", AJS.params.currentUserFullname, "visit"]);

		var d = document, 
			g = d.createElement('script'), 
			s = d.getElementsByTagName('script')[0];         
		g.type = 'text/javascript'; 
		g.defer = true; 
		g.async = true; 
		g.src = u + 'piwik.js';
<!-- End Piwik Code || Edited 1/9/2015, working with version 5.3.4 of confluence-->

I added bellow code in my javascript function but unique visitors count of custom variables is showing blank in piwik. ![piwik1]( var u=(("https:" == document.location.protocol) ? "https" : "http") + "://"+paq_url+"/"; _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['setSiteId', paq_site_id]); _paq.push(['setUserId', userId]); _paq.push(['setCustomVariable', '3','Full Text Search User Types',userType,'visit']); _paq.push(['trackPageView']); _paq.push(['trackSiteSearch',keyword,category,searchCount]); I am using piwik 2.15.0 , Please help me

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events