Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Confluence analytics, individual space stats & Piwik

Andrei [errno]
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.
December 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

4 votes
Answer accepted
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.
December 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]
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.
December 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 at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
March 8, 2012

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

Sean King
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.
May 14, 2013

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.

1 vote
Eric Hammes January 12, 2015

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-->
santhosh Devadiga November 18, 2015

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
TAGS
AUG Leaders

Atlassian Community Events