Help:Adding statistics to your page

From UBC Wiki
Jump to: navigation, search

In UBC Wiki, you can use the googleanalyticsmetrics function to add statistics to your page. Adding statistics to the page can be very useful when you reflect the resource/course/pages you have created.


Ambox warning yellow.png Unfortunately, the statistics between July 17,2018~ August 18,2018 are uncounted due to the migration process. We are very sorry for the inconvenience.

Usage

The googleanalyticsmetrics parser function takes two parameters, in the form of {{#googleanalyticsmetrics: metric=pageviews|page=Page Name|startDate=Start date|endDate=End date}}:

  • Page Name
The name of the page. For example, if you are adding a statistics for the page Sandbox:AddingStatistics, it will be Sandbox:AddingStatistics.
  • Start date
Show the metric since this date (optional). Defaults to 2005-01-01, which is the beginning of time according to Google Analytics.
  • End date
Show the metric until this date (optional). Defaults to today.
Both date parameters use the form: Year-Month-Day.

Example

This example displays the number of page views for this site, from the beginning until the end of time. You can copy and paste the code both in the Visual Editor and wikitext. In Visual Editor, after you have copy and paste the code, click on the code and edit the parameter as you wish.

Paste the example code to the visual editor and press edit. Then, Change the parameter and press Apply changes.

Show the number of pageviews for all of the UBCWiki pages

 {{#googleanalyticsmetrics: metric=pageviews}}

Show the number of pageviews for Help:Adding statistics to your page

{{#googleanalyticsmetrics: metric=pageviews|page=Help:Adding statistics to your page}}

Show the number of pageviews for Help:Adding statistics to your page from Febuary 3, 2017 until today.

{{#googleanalyticsmetrics: metric=pageviews|page=Help:Adding statistics to your page|startDate=2017-02-03}}

Show the number of pageviews for Help:Adding statistics to your page from Febuary 3, 2017 to Dec 31,2017.

{{#googleanalyticsmetrics: metric=pageviews|page=Help:Adding statistics to your page|startDate=2017-02-03|endDate=2017-12-31}}

Best Practices

  • Since adding the code will just show up the no. pageviews, it will be user-friendly if you add a text or a heading such as - "no. of pageviews "