×

You're using an outdated browser

For a better experience, keep your browser up to date. Check here for the latest version.

Manual

Trigger EliteSofts Page View Macro through Scroll Viewport

Steffen Burzlaff

Steffen Burzlaff Last update: Feb 14, 2019

The Page View Macro for Confluence from EliteSoft is a simple tool to track Confluence page views (including anonymous views) and can be setup to work alongside Scroll Viewport. 

Implementation

The Page View Macro performs a REST Call to the following URL and hands over the ID of the current page to trigger a page view: 

<base-url>/rest/page-tracking-services/1.0/page-tracking/page-view 

Therefore, to track page views of visitors in your Viewport view, you need to add some code to your theme. 

  1. Firstly, you need the confluence-base-url and the ID of the current page in your theme so that you can execute the REST Call. You can save this information easily in a your HTML head like this:

    <meta name="pageId" content="${page.id}">
    <meta name="ajs-base-url" content="${baseUrl}">
  2. Next, you need to do the REST Call to Confluence and the Page View Macro. To do this you need to grab the content of both meta-tags. The best way to do this, is to integrate the REST Call in an external JavaScript file with jQuery which is referenced in your theme:

    $(document).ready(function() {
    	var pageId  = $('meta[name="pageId"]').attr('content');
    	var baseUrl = $('meta[name="ajs-base-url"]').attr('content');
    	var url     = baseUrl + "/rest/page-tracking-services/1.0/page-tracking/page-view";
    
    	$.ajax({ 
       		url: url, 
       		type: 'PUT',
       		data: {'pageId': pageId}
    	});
    });

    This means we get the information of previously added meta-tags and save them into variables. 

  3. After this, you need to create the required URL and perform the REST Call with the ID of the page as a parameter.


2x2.12
We use cookies to create a secure and effective browsing experience for our website visitors and to understand how you use our site (i.e. Google Analytics). For more information: click here.
Ok