Scroll Viewport - Page view Statistics/Analytics
Asked by Bandy:

Hi,

I have the "Page View" Plugin installed as well have the "Activity" tracker enabled in my Confluence space (Scroll Version). As such I can view the activity details and page view statistics in my working space (Scroll Version).

My audience refers to content using Viewport.

My Query: **Is there a way/plugin that enables me to collect analytics on activities in Viewport? Page Hits/User details etc?**

Regards,

Bandy


Answers:
author: Steffen Burzlaff _K15t_
body: Hi Bandy,

"**Is there a way/plugin that enables me to collect analytics on activities in Viewport? Page Hits/User details etc?"**

Sure this is possible. I assume you are using the "Page View" plugin from EliteSoft?

The plugin is using an Ajax call to track the page view in Confluence.  

So what you would have to do, is performing a PUT-Request in your Viewport Theme if a page is visited.  

To achieve that you would need to call this URL via an Ajax call.

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

To get the current page ID you would have to insert the following into your HTML-Head, which needs to be available on every page you want to track.

    <meta name="pageId" content="${page.id}">

You can access this information with the following JavaScript (this is using jQuery) and send it over to the tracking plugin:

Paste this code into your document.ready function. If you are using the Scroll Web Help Theme you will find this function inside the: theme.main.js file.

```
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}
});?  
```

If you don't want to track your own data you could exclude the specific user-group by adding a if statement around (either the script or around the meta tags) which check the current user-group.

```
#if($user.isInGroup(groupName))
 <meta tags>
#end
```

or create a meta tag for the user-group and check it in your JavaScript.

<br />

Hope this is solving your problem.  

Let me know if it works out for you. Thanks and have a nice day.

Best,  
Steffen

comments: author: Bandy
body: Thank you Steffen.

I will try and work on your solution to see if it works for me. Am not much of a tech person so am not sure if I can implement this solution. Will take some help from my tech guys here and will keep you updated.

Regards,

Bandy


author: Bandy
body: Hi Steffen,

I updated the theme as suggested in your response above. Am not able to see the page hit numbers anywhere.

Can you please let me know where the page view hit details is getting reflected/stored?

Regards,

Bandy


author: David _K15t_
body: Hi Bandy,

who is your audience? Do they have Confluence accounts or are they anonymous?

We at K15t present our help.k15t.com content to anonymous users using Viewport and we use Google Analytics to keep track of views etc. That way we can also ignore all activities by logged in employees, so we don't distort the data.

Cheers,

David

comments: author: Bandy
body: Hi David,

My audience for Viewport is anonymous.

Thank you. I will try and explore Google Analytics.

Regards,

Bandy


author: shehzad.iqbal
body: Hi [@David _K15t_](/t5/user/viewprofilepage/user-id/1212853) ,   

How can we do the same? How do we insert the GA tracking code in the viewport? The view port seems to ignore the script added to Global Custom HTML.


author: Adriane Hunt
body: I am also experiencing a similar problem. ScrollViewport seems to ignore the standard Confluence GA setup with Custom HTML.


author: shehzad.iqbal
body: We were later able to do this by customizing/adding the code to the theme's page.vm.


author: Steffen Burzlaff _K15t_
body: Hi [@shehzad.iqbal](/t5/user/viewprofilepage/user-id/2307704) and [@Adriane Hunt](/t5/user/viewprofilepage/user-id/2686464) ,

Scroll Viewport is grabbing the content only from the Confluence page itself. This means, every HTML which isn't in the page content of the Confluence page isn't available in the viewport. The Global Custom HTML is one of those cases.  
As Shehzad already figured out - you would need to put the GA code directly into your theme (page.vm).  

Scroll Viewport comes now with a new and customizable [Help Center Theme](https://help.k15t.com/scroll-viewport/latest/the-help-center-theme-168363702.html "Help Center Theme") which also offers a [Google integration](https://help.k15t.com/scroll-viewport/latest/integrations-168363871.html "Help Center Theme Integrations") out of the box. You just need to enter your Google Tracking ID and won't have to enter a code by yourself.

Cheers,

Steffen


author: David _K15t_
body: The new Help Center theme supports the GA integration out of the box. Just input your AnalyticsID or Tag Manager ID in the properties and you're good to go. More on that here: <https://help.k15t.com/scroll-viewport/latest/integrations-168363871.html#id-.Integrationsv2.15-Third-PartyIntegrations>


author: Adriane Hunt
body: Steffen, David,

Thank you both for the helpful information! I implemented the GA code in our WebHelp theme and it's working flawlessly! I also took a look at the new Help Center theme (Nice!) and might implement a version of it in the future. Many thanks!

Regards,

Adriane


Tags: analytics

scroll-viewport