Contentsquare icon

Contentsquare

Use the Contentsquare API

Actions76

Overview

This node integrates with the Contentsquare API to retrieve detailed user behavior and performance metrics related to web pages. Specifically, the "Get Page Time Spent" operation under the "Metrics API" resource fetches the average time visitors spend on a particular page group, measured from the first page view event to the last event sent.

This node is beneficial for digital analysts, marketers, and UX designers who want to understand user engagement on specific pages of their website or app. For example, it can help identify which pages hold users' attention longer, indicating content effectiveness or usability.

Practical examples:

  • Measuring how long users spend on a product detail page to assess interest.
  • Comparing time spent across different device types (desktop, mobile, tablet).
  • Analyzing time spent trends over a date range to evaluate the impact of recent changes.

Properties

Name Meaning
Page Group ID Numeric identifier of the page group for which the time spent metric is requested. This is required to specify the target page group.
Query Parameters A collection of optional filters and settings to refine the query:
- Device: Filter by device type (all, desktop, mobile, tablet).
- End Date: End of the date range for analysis.
- Format: Format of the query date range.
- Frequency: Export frequency filter.
- From: Export format filter.
- Goal ID: Conversion goal identifier for non-ecommerce goals.
- IDs: Comma-separated list of segment IDs to filter results.
- Limit: Maximum number of results to return (default 50).
- Metric Type: Metric calculation method (Quantile or Average).
- Order: Sort order of results (Ascending or Descending).
- Page: Pagination page number.
- Period: Granularity of results (daily or none).
- Project ID: Target project identifier (required for account-level API keys).
- Quantile: Percentile value used if metric type is quantile (default 75).
- Scope: Scope filter.
- Segment IDs: Multiple segments separated by commas for intersection filtering.
- Start Date: Start of the date range for analysis.
- State: Status filter.
- To: End date of the query date range.

Output

The output JSON contains the response data from the Contentsquare API endpoint for page time spent metrics. The structure depends on the API's response but generally includes:

  • Metrics about average time spent on the specified page group.
  • Data filtered and segmented according to the provided query parameters.
  • Possibly paginated results depending on the limit and page parameters.

If the API returns no content, the node outputs a status code message indicating "204 No Content".

The node does not output binary data.

Dependencies

  • Requires an API key credential with client ID, client secret, project ID, and scope configured in n8n credentials.
  • Makes authenticated HTTP requests to the Contentsquare API OAuth token endpoint to obtain an access token.
  • Uses the obtained access token to authorize subsequent API calls.
  • Requires internet connectivity to reach the Contentsquare API endpoints.

Troubleshooting

  • Missing Client ID or Client Secret: The node will throw an error if these credentials are not set. Ensure that the API key credential is properly configured.
  • Failed to retrieve access token or endpoint: Indicates issues with authentication or API availability. Verify credentials and network connectivity.
  • Required parameter missing errors: For this operation, "Page Group ID" must be provided; otherwise, the node throws an error.
  • API call failures: Errors returned from the API are wrapped and presented with messages like "Error calling Contentsquare API". Check the API response and ensure parameters are valid.
  • Empty or unexpected responses: If the API returns empty data or unexpected formats, verify the query parameters and date ranges.

Links and References

Discussion