Confluence analytics, individual space stats & Piwik

Andrei [errno] Community Champion Dec 16, 2011

I would like to colect user access statistics and Piwik (http://piwik.org) 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: example.com/confluence/display/TEAMSPACE
  • 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

This widget could not be displayed.
David Simpson Community Champion Dec 16, 2011

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
	_gaq.push(['_setCustomVar',
		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.

Andrei [errno] Community Champion Dec 17, 2011

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 :)

David Simpson Community Champion Mar 08, 2012

@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.

This widget could not be displayed.

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">
	//https://confluence.atlassian.com/display/CONFKB/How+to+Use+JavaScript+in+Confluence
	var _paq = _paq || [];

	AJS.toInit(function(){   
		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"]);
		_paq.push(['enableLinkTracking']);
		_paq.push(['trackPageView']);

		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';
		s.parentNode.insertBefore(g,s); 
	})();
</script>
<!-- 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](https://cloud.githubusercontent.com/assets/5286315/11184714/24f1520c-8c9f-11e5-8468-2c73928c6ebd.PNG) 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
Community showcase
Posted Monday in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

468 views 6 6
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