Piwik\

SiteContentDetector

This class provides detection functions for specific content on a site.

Note: Calling the detect() method will create a HTTP request to the site to retrieve data, only the main site URL will be checked

Usage:

$contentDetector = new SiteContentDetector(); $contentDetector->detectContent([SiteContentDetector::GA3]); if ($contentDetector->ga3) { // site is using GA3 }

Properties

This class defines the following properties:

$consentManagerId

Signature

  • Its type is not specified.

$consentManagerName

Signature

  • Its type is not specified.

$consentManagerUrl

Signature

  • Its type is not specified.

$isConnected

Signature

  • Its type is not specified.

$ga3

Signature

  • Its type is not specified.

$ga4

Signature

  • Its type is not specified.

$gtm

Signature

  • Its type is not specified.

$cms

Signature

  • Its type is not specified.

$cloudflare

Signature

  • Its type is not specified.

$jsFramework

Signature

  • Its type is not specified.

Methods

The class defines the following methods:

  • __construct()
  • detectContent() — This will query the site and populate the class properties with the details of the detected content
  • getConsentManagerDefinitions() — Return an array of consent manager definitions which can be used to detect their presence on the site and show the associated guide links

__construct()

Signature

  • It accepts the following parameter(s):
    • $cache (Matomo\Cache\Lazy|null) —

detectContent()

This will query the site and populate the class properties with the details of the detected content

Signature

  • It accepts the following parameter(s):
    • $detectContent (array) — Array of content type for which to check, defaults to all, limiting this list will speed up the detection check
    • $idSite (int|null) — Override the site ID, will use the site from the current request if null
    • $siteResponse (array|null) — String containing the site data to search, if blank then data will be retrieved from the current request site via an http request
    • $timeOut (int) — How long to wait for the site to response, defaults to 5 seconds
  • It returns a void value.

getConsentManagerDefinitions()

Return an array of consent manager definitions which can be used to detect their presence on the site and show the associated guide links

Note: This list is also used to display the known / supported consent managers on the "Ask for Consent" page For adding a new consent manager to this page, it needs to be added here. If a consent manager can't be detected automatically, simply leave the detections empty.

Signature

  • It returns a array value.