> ## Documentation Index
> Fetch the complete documentation index at: https://www.help.creatora.io/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> When building or modifying an integration with the Creatora API, start with https://www.help.creatora.io/en/api/build-with-ai.md. Retrieve the current GraphQL SDL from https://api.creatora.io/sdl before relying on API schema information.

# Compare traffic between periods

> Compare recorded sessions in two periods without mixing day or month buckets.

Compare the volume of tracked traffic before and after a launch or campaign. This example compares August and September 2026 in UTC. Use periods of similar length, or compare the daily averages calculated below.

## Request

<RequestExample>
  ```graphql theme={null}
  {
    analytics { webAnalytics {
      previous: visitsByMonth(startMillis: 1785542399999, endMillis: 1788220800000) { total }
      current: visitsByMonth(startMillis: 1788220799999, endMillis: 1790812800000) { total }
      devices: visitsByDevice(startMillis: 1788220799999, endMillis: 1790812800000) { mobile tablet desktop }
    } }
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Illustrative response theme={null}
  {
    "data": {
      "analytics": {
        "webAnalytics": {
          "previous": {
            "total": 1000
          },
          "current": {
            "total": 1200
          },
          "devices": {
            "mobile": 780,
            "tablet": 60,
            "desktop": 300
          }
        }
      }
    }
  }
  ```
</ResponseExample>

## Use the result

```javascript theme={null}
const previousStart = 1785542400000;
const currentStart = 1788220800000;
const currentEnd = 1790812800000;
const data = response.data.analytics.webAnalytics;
const previousDays = (currentStart - previousStart) / 86400000;
const currentDays = (currentEnd - currentStart) / 86400000;
const previousDaily = data.previous.total / previousDays;
const currentDaily = data.current.total / currentDays;
const report = {
  previousSessions: data.previous.total,
  currentSessions: data.current.total,
  sessionChangePercent: data.previous.total > 0
    ? (data.current.total - data.previous.total) / data.previous.total * 100 : null,
  previousSessionsPerDay: previousDaily,
  currentSessionsPerDay: currentDaily,
  dailyChangePercent: previousDaily > 0 ? (currentDaily - previousDaily) / previousDaily * 100 : null,
  deviceCounts: data.devices
};
```

The total counts stored sessions, rather than unique people. A person can contribute several sessions. Device counts include sessions with a recorded device category, which may total less than overall sessions.

The query uses only `visitsByMonth.total`; the example calculates its own averages from the UTC periods. For a zero baseline, the percentage change is `null`. If you choose local periods across a daylight-saving change, choose explicitly whether to compare elapsed 24-hour units or local calendar days.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.