How to install Matomo (formerly Piwik) web analytics software on our Apache server (page 3)

botond published 2019/09/01, v - 16:03 time

Content

 

3. page content

 

 

Continuation

Az previous page we installed the Matomo (Piwik) web statistics system, we will continue here by placing the tracking codes in WordPress web pages. Setting up the plug-in isn't complicated, I'd rather make this part of the description so that those who are still thinking about installing the Matomo system can anticipate the options the plug-in offers.

 

Placing tracking code on WordPress pages

If WordPress based CMS system page to put your Matomo tracking code, then the simple thing is to just download the right WordPress plugin and configure it.

Install plugin

The Matomo official installer starting from the manufacturer we officially recommended WordPress plugin page. So this is what we need to look for in the plugin manager section of the web page admin (Admin - Add-ons - Add New - Search for "matomo"):

WordPress admin - Find Matomo plugin

Yes, here is the very first one, let's not worry about the rest. Install it and turn it on. Then the system will drop you back into the list of installed extensions:

WordPress admin - Add-ons installed

Here at WP-Matomo, click on settings, then the plugin configuration page will appear:

Connecting to Matomo tab

WordPress admin - WP-Piwik Options - Join the matomo

Here are the settings:

  • Visible mode: Leave it here by default (HTTP API).
  • Visible URL: Specify the path to your Matomo instance. For example the mentioned earlier from the directory under the website. Here, "set to home hosts file" domain name does not accept by default, because in this case the server is also an external one DNS is trying to resolve the name so it can't find it on your machine Virtual hosting-him. You would need to configure the server to do this / Etc / hosts file into is the domain name with the server's own IP address. But for now, the virtual machine IP addresses I use matomo access below.
  • Authorization Token: Here you need to enter a long hex code to identify yourself through the API. We'll see how we can get it.
  • Automatic configuration: If you have not previously added the web site to Matomo, this is another web page, etc., this option allows this plugin to now create this web page in Matomo as a new page. If it is already on the system, it does not matter whether it is enabled.

Obtaining an Authorization Token

Switch to the Matomo interface, making sure that this page is set in the Page Selector drop-down under the header. Then click the gear icon to the right of the header. Then you will see the Matomo main settings page. Scroll down here until you find the API submenu (in the Platform group) in the left menu bar. Click the API menu and the API settings page will appear:

Matomo - Preferences - API

Here, the ID is first starred in the gray bar. Click on it, then the whole thing will come out, who will also copy it to the clipboard for us. Let's go back to the WordPress Piwik settings, then we only need the part of the code after the equal sign from the copied line, we insert this in the Authorization token field above, cutting off the "& token_auth =" part from the beginning.

When you're done with the form, click the Save Changes button. Upon successful connection, we will receive the following window:

WordPress admin - WP-Piwik Options - Successful connection

Go to the next tab.

 

 

Show Statistics tab

Use this tab to customize Matomo statistics displayed by the plugin in the WordPress admin interface. I will not go into these now, because this is not the subject of this description, I will only show two pictures of the settings, where I also opened the help:

WordPress admin - WP-Piwik Options - Show stats (Image 1)

WordPress admin - WP-Piwik Options - Show stats (Image 2)

So here you can set up a highly customizable statistical interface on the admin interface of our WordPress site, which extracts data from Matomo using the API.

Enable tracking tab

The point here is: we need to enable the operation of the whole statistical system, as well as we can fine-tune the operation of the measurement code (here, due to the size of the form, I have divided the explanation of the settings into several parts):

WordPress admin - WP-Piwik Options - Enable tracking (Image 1)

  • Add tracking code: Here you can choose from several tracking methods. If there is no particular reason to deviate from normal operation, select Default tracking. This is normal HTTP HTTPS provides measurement through a link, which is recommended in most cases.
  • tracking: This is a preview or editor field for JavaScript tracking code. If you do not select the "Enter manually" option above, it will remain blank for the time being, and after saving the form, you will enter a code preview after all options have been set. This way, we'll have nothing to do, just check the code itself.
    And if you chose manual, then this textbox becomes writable and you can paste the code we've made or just what Matomo offered us in the page.

WordPress admin - WP-Piwik Options - Enable tracking (Image 2)

  • JavaScript code position: Set this to the header. Matomo also recommends that a member.
  • Noscript code: This piece of code (mostly a link to a URL resource) runs when the visitor's browser does not have JavaScript enabled. Nowadays this is not very common, so it is more suitable for tracking robots that do not execute JavaScript code. We can't edit here either, this will be a preview after saving the form.
  • Add: Here you can enable the aforementioned Noscript section.
  • To assign the rec parameter to the noscript code: Adds another option to the Noscript section.
  • To enable content tracking: Here you can control what types of content Matomo follows in your WordPress system
  • Follow Search: You can enable tracking of page searches here.
  • Follow 404: We can also control the tracking of error pages
  • Add annotation on new post of type: If a new entry is created for the content types set here, it will place a comment on the timeline in Matomo statistics.

WordPress admin - WP-Piwik Options - Enable tracking (Image 3)

  • Show Custom Variables Box: If enabled, the WordPress content editor will display a box with the variables that can be used. These variables allow us to track unique and targeted content across our various content.
  • To add new file types to download tracking: The file extensions listed here will be registered by Matomo as a download and will be associated with a different event type than a normal page download. For example, if we offer zip, gzip, etc. downloads on our site, we can list these extensions here, which can then be displayed separately in the statistics for queries.
  • Disable cookies: Disables tracking cookies. Its use is not recommended because it degrades tracking accuracy.
  • To limit the life of a cookie: Here we can determine how long it will take for a visitor to be considered a new session by Matomo. When enabled, 3 more fields are displayed: Visitor Timeout (in seconds), Session Timeout (in seconds), Link Timeout (in seconds). These can be fine-tuned in this case.
  • Follow Admin Pages: When enabled, visits to admin are also forwarded to Matomo by this WordPress plugin.
  • Tracking filter: If this admin page tracking is enabled, here you can select which user levels to follow.
  • Follow subdomains on the same web page: If enabled, it prefixes visits with subdomains. This makes it easier to distinguish between statistics. Eg language subdomains, etc.
  • Do not count subdomains for exit links: If enabled, transitions between subdomains are not considered an exit point.
  • Enable cross domain linking: If enabled, visits to domains / webpages under our own management will be assigned a unique identifier, so no duplicate identifiers on two webpages can occur.

WordPress admin - WP-Piwik Options - Enable tracking (Image 4)

  • Follow RSS feeds: When turned on, our RSS feeds are also tracked with an added pixel.
  • Track RSS feed links per campaign: You follow RSS feeds individually, as a campaign.
  • RSS Feed Campaign: If the previous one is enabled, you can enter the RSS feed name here.
  • Enable Heartbeat Timer: If we set a value of one second here, JavaScript will send a "life signal" to the Matomo server at such times, resulting in more accurate visit times. As a result of the feature, the increased HTTP traffic also puts a heavier load on the server. So set the optimal value here. 0 value = disable function.
  • User ID Tracking: Here you can choose what ID you want to add to your visits within WordPress. Here, I recommend the WP User ID, as this will allow you to work more flexibly in databases, if needed.

These would be the tracking enable settings. Once we have set everything up according to our needs, save the form. When you return to the same tab after saving, your tracking code will appear. Of course, let's just look at it as interesting.

These settings are already sufficient to measure your WordPress page.

A Advanced settings Modify the options below the tab only if a service or situation specifically requires it. Otherwise, all settings are set here for normal operation.

 

 

Testing

Once you have successfully configured and saved everything, you can test Matomo (Piwik) web stats by going to WordPress and looking at Matomo in a few clicks:

Matomo - Testing a New Page

And here are the first measured page downloads, graphs, etc.

 

A next page we will continue to implement the tracking code for Drupal web pages.

 

 

Navigation

This description consists of several pages: