Pages

Before you can use the data layer with the Frosmo Platform, you must enable the data layer module for your site. You do this from the Frosmo Control Panel or by using the Graniitti API. When enabled, the module initializes the data layer on page load by creating the global window.dataLayer array. If window.dataLayer already exists, the module uses the existing variable.

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.

Only certain Frosmo users can enable and disable site modules. If you're a company user, your Frosmo team enables and disables the modules for your site.

Enabling and disabling the data layer using the Frosmo Control Panel

To enable the data layer for a site:

  1. In the Control Panel, click your user name, and select Company Settings.

    Enabling the data layer for a site

  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'

    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'

    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 Authentication and Requests in the Graniitti API guide.

  • No labels