Skip to main content

Enabling and disabling the data layer

Before you can use the Frosmo data layer on a site, you need to enable the data layer module for the site. You do this in the Frosmo Control Panel or by using the Graniitti API.

When enabled, the data layer module initializes the data layer on page load by creating the global window.dataLayer array. If window.dataLayer already exists on the page, the module uses the existing array.

note

Only certain Frosmo users can enable and disable site modules. If you're a company-user, a Frosmo user enables and disables the modules for your site. For more information, contact Frosmo support.

note

Enabling or disabling the data layer module for a site has no impact on data passed to Google Tag Manager. The data layer module is a Frosmo Platform feature and only affects data passed to the Frosmo JavaScript library.

Enabling and disabling the data layer using the Frosmo Control Panel

To enable the data layer for a site:

  1. In the Frosmo Control Panel, in the header, click your username, and select Company.

  2. Click the quick menu button for the site, and select Set modules.

    Enabling the data layer for a site
  3. Click Add for Data layer.

    Enabling the data layer for a site
  4. Click Close.

You have enabled the data layer for the site. You can now push data to the data layer.

To disable the data layer for the site, follow the above steps, but click Active for Data layer.

Disabling the data layer for a site

Enabling and disabling the data layer using the Graniitti API

To enable the data layer for a site:

  1. Send a PATCH request to /companies/<company_id>/settings/data_layer_enabled with the value property in the request body set to true. This enables the data layer module for the site.

    curl -X PATCH \
    --header 'Authorization: Bearer <access_token>' \
    --header 'Content-Type: application/json' \
    -d '{"value":true,"site_id":<site_id>}' \
    'https://<graniitti_api_domain>/v0/companies/<company_id>/settings/data_layer_enabled'
    note

    Use the correct access token, site ID, domain name, and company ID in the request.

  2. Send a POST request to /sites/<site_id>/js/export. This updates the custom script for the site, so that your changes are actually reflected on the site.

    curl -X POST \
    --header 'Authorization: Bearer <access_token>' \
    'https://<graniitti_api_domain>/v0/sites/<site_id>/js/export'
    note

    Use the correct access token, domain name, and site ID in the request.

You have enabled the data layer for the site. You can now push data to the data layer.

To disable the data layer for the site, follow the above steps, but set the value property in the PATCH request body to false.

curl -X PATCH \
--header 'Authorization: Bearer <access_token>' \
--header 'Content-Type: application/json' \
-d '{"value":false,"site_id":<site_id>}' \
'https://<graniitti_api_domain>/v0/companies/<company_id>/settings/data_layer_enabled'

For more information about Graniitti API requests, see the Graniitti API guide.