OnyxMetric
Integration Guides

TYPO3

Add OnyxMetric analytics to your TYPO3 site

TYPO3 sitepackages build the page <head> from TypoScript rather than an HTML template. Add the script as a page.includeJS entry in your sitepackage's setup file.

Copy your tracking snippet

In OnyxMetric, open your site's Site Settings and copy the tracking script. It looks like this:

<script src="https://app.onyxmetric.com/api/script.js?siteId=YOUR_SITE_ID" async></script>

YOUR_SITE_ID is the numeric ID of your site.

Add the snippet to TYPO3

  1. Open your main TypoScript setup file, usually <sitepackage>/Configuration/TypoScript/setup.typoscript. It is the one that already contains page = PAGE.

  2. Add the script to the page object:

    page = PAGE
    page {
      includeJS {
        onyxmetric = https://app.onyxmetric.com/api/script.js?siteId=YOUR_SITE_ID
        onyxmetric.async = 1
      }
    }

    The site ID is part of the URL, so no data-* attribute is needed and this works on every supported TYPO3 version.

  3. To track production only, wrap the include in an applicationContext condition:

    [applicationContext == "Production"]
    page.includeJS.onyxmetric = https://app.onyxmetric.com/api/script.js?siteId=YOUR_SITE_ID
    page.includeJS.onyxmetric.async = 1
    [END]
  4. Optionally keep the ID in constants.typoscript so the setup file can be committed without site-specific values:

    # constants.typoscript
    onyxmetric {
      siteId = YOUR_SITE_ID
    }
    
    # setup.typoscript
    page.includeJS.onyxmetric = https://app.onyxmetric.com/api/script.js?siteId={$onyxmetric.siteId}
    page.includeJS.onyxmetric.async = 1
  5. Deploy the sitepackage and flush the TYPO3 caches.

Check that it works

Load your live site and click through a few pages. Pageviews show up in the OnyxMetric dashboard within seconds.

If nothing arrives:

  • View the page source and search for script.js?siteId= to confirm the tag is present.
  • In the browser's Network tab, check that script.js returns 200 and that requests go to /api/track.
  • Turn off ad blockers, or proxy the script through your own domain.
  • Read script troubleshooting for other causes.

Troubleshooting

  • Script not in the page source: TYPO3 caches rendered pages. Flush caches from the backend toolbar or run vendor/bin/typo3 cache:flush.
  • Wrong TypoScript file: if several files define page, open the TypoScript object browser and check the resulting page.includeJS.
  • Condition never matches: applicationContext comes from the TYPO3_CONTEXT environment variable. If it is unset, TYPO3 runs as Production, so check the value on each environment.

Next steps

On this page