famouswolf/matomoapi

TYPO3 extension to talk to Matomo API and display it with a template

Installs: 19

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 0

Open Issues: 0

Type:typo3-cms-extension

1.0.1 2021-05-17 08:02 UTC

This package is auto-updated.

Last update: 2024-12-17 21:43:53 UTC


README

TYPO3 extension to connect to the Matomo API and show the result using a Fluid template.

Requirements

  • TYPO3 CMS 10.4
  • PHP 7.2+
  • Licence: GPL 3.0

Manual

After installing the extension you need to configure the Matomo API call through TypoScript. You can then add the plugin, either through TypoScript or as a content element. The default template will show the returned data using f:debug, so most likely you'll want to create a custom template.

More about the Matomo API can be found here: https://developer.matomo.org/api-reference/reporting-api

TypoScript

Examples

Get the number of visits in the last 30 days

TypoScript
plugin.tx_matomoapi {
  settings {
    apiUrl = https://example.org/matomo/index.php?
    tokenAuth = 1234567890abcdef1234567890abcdef
    method = VisitsSummary.get
    parameters {
      idSite = 1
      period = range
      date = last30
    }
  }
}
Fluid template
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers">
<f:layout name="Default" />

<f:section name="Content">
    Visits in the last 30 days: {data.nb_visits}
</f:section>
</html>

Get the most visited page URL for yesterday

TypoScript
plugin.tx_matomoapi {
  settings {
    apiUrl = https://example.org/matomo/index.php?
    tokenAuth = 1234567890abcdef1234567890abcdef
    method = Actions.getPageUrls
    parameters {
      idSite = 1
      period = day
      date = yesterday
      flat = 1
      filter_limit = 1
    }
  }
}
Fluid template
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers">
<f:layout name="Default" />

<f:section name="Content">
    <f:if condition="{data.0}">
        <f:then>
            <a href="{data.0.url}">Most visited page yesterday</a>
        </f:then>
        <f:else>
            There were no visitors yesterday or something went wrong
        </f:else>
    </f:if>
</f:section>
</html>