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 website zones, pages, sites, and exports. Specifically, the "Get Zone Revenue" operation under the "Metrics API" resource fetches the total revenue generated by users segmented by their interaction with a specific zone (an element or area on a webpage). This is useful for understanding how different page elements contribute to revenue, enabling data-driven optimization of web layouts and marketing strategies.

Common scenarios include:

  • Measuring the financial impact of clickable zones or interactive elements on a website.
  • Analyzing revenue attribution to specific UI components or campaigns.
  • Segmenting revenue data by device type, date ranges, or other filters to refine marketing efforts.

Example: A marketer wants to know how much revenue was generated from users who clicked on a promotional banner zone during a holiday campaign. Using this node, they can specify the zone ID and date range to get precise revenue metrics.

Properties

Name Meaning
Zone ID Numeric identifier of the zone (page element) for which to retrieve revenue metrics. Required for this operation.
Query Parameters Collection of optional filters and settings to refine the query results:
- Device Filter by device type: All, Desktop, Mobile, Tablet. Default is All.
- End Date End date of the analysis period (must be after Start Date).
- Format Format of the query date range (string, usage depends on API specifics).
- Frequency Filter based on export frequency (string).
- From Filter based on export format (string).
- Goal ID Numeric ID to return conversion metrics for a non-ecommerce goal.
- IDs Comma-separated list of segment IDs to filter results.
- Limit Maximum number of results to return. Default is 50. Minimum value is 1.
- Metric Type Metric aggregation type: Quantile or Average. Default is Quantile.
- Order Sort order of results: Ascending or Descending. Default is Descending.
- Page Page number of results to retrieve (for pagination).
- Period Granularity of results: Daily or None. Can only be used if date range is larger than one day. Default is None.
- Project ID Target project ID (required only for account-level API keys).
- Quantile Percentile to use if metric type is Quantile. Default is 75. Ignored if metric type is Average.
- Scope Filter based on scope (string).
- Segment IDs Numeric segment IDs separated by commas to retrieve metrics for intersection of specified segments.
- Start Date Start date of the analysis period (must be before End Date).
- State Filter based on status (string).
- To End date of the query date range (string).

Output

The node outputs an array of JSON objects representing the response from the Contentsquare API for the requested zone revenue metrics. The structure depends on the API response but typically includes fields such as:

  • Total revenue generated by users interacting with the specified zone.
  • Breakdown by time periods or segments if filters are applied.
  • Additional metadata about the query or metrics.

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

No binary data output is indicated for this operation.

Dependencies

  • Requires valid Contentsquare API credentials including Client ID, Client Secret, and optionally Project ID and Scope.
  • The node performs OAuth2 client credentials flow to obtain an access token before making API requests.
  • Network access to https://api.contentsquare.com is required.
  • Proper configuration of credentials in n8n is necessary to authenticate API calls.

Troubleshooting

  • Missing Credentials: If Client ID or Client Secret are not provided, the node throws an error "Missing Client ID or Client Secret."
  • Access Token Retrieval Failure: If the OAuth token cannot be obtained, errors like "Failed to retrieve access token" or "Failed to retrieve endpoint" occur.
  • Required Parameter Missing: For this operation, if Zone ID is not set, the node throws "Zone ID is required".
  • API Errors: Any HTTP or API errors are caught and rethrown with the message prefix "Error calling Contentsquare API:" followed by the original error message.
  • Invalid Query Parameters: Ensure date ranges are valid (startDate before endDate), numeric IDs are correct, and options conform to allowed values.
  • Empty Response: If the API returns no data, the node outputs a "204 No Content" status; verify that the query parameters match existing data.

Links and References

Discussion