Sitewide Method addToSitewidePageBody()

public function addToSitewidePageBody(
$canSetAnalytics, $canSetSocialMedia
) { //...your PHP code...// }
 

Summary

This method lets you write HTML immediately after the <body> tag of every content item on the site.

Where You Can Use It

From Zenario 10.4 onwards, in modules with the adds_sitewide_html property set in their description.yaml file.

Description

If you have set the adds_sitewide_html property in your module's description.yaml file then Zenario will call your module's addToSitewidePageBody() function every time a content item is displayed.

This lets you output HTML that will appear just after the <body> tag of the page is opened.

Parameters

$canSetAnalytics

Use this to check whether you are allowed to set analytics cookies.

For sites using the Don't inform or the Implied consent options, this will always be true.

For sites using the Explicit consent options, this will be true if the visitor has opted into analytics cookies, or has pressed the "Accept all" button.

$canSetSocialMedia

Use this to check whether you are allowed to set cookies from social media.

For sites using the Don't inform or the Implied consent options, this will always be true.

For sites using the Explicit consent options, this will be true if the visitor has opted into cookies from social media, or has pressed the "Accept all" button.

Return Value

No return value is needed.

Example

public static function addToSitewidePageBody($canSetAnalytics, $canSetSocialMedia) {
    if ($canSetAnalytics) {
       echo '<img src="analytics/track.gif" width="1" height="1" alt="">';
    }
}