# Preview & Live Log

URL: https://docs.ablyft.com/developers/debugging/preview-and-live-log/

> Debug mode, preview mode, the QA tool, forced variations and the Live Log.



This page describes the tools that show you what ABlyft does on a page and which events it sends.

| Tool                                    | Use it to                                                  |
| --------------------------------------- | ---------------------------------------------------------- |
| [Debug mode](#debug-mode)               | See in the console why experiments run or do not run       |
| [Preview mode](#preview-mode)           | Look at a variation without being part of the real traffic |
| [QA tool](#qa-tool)                     | Check targeting and goals while you click through the site |
| [Force a variation](#force-a-variation) | Show a specific variation from your own code               |
| [Live Log](#live-log)                   | See the events that ABlyft really received                 |

## Debug mode

Debug mode writes the decisions of the snippet to the browser console. Each line starts with `ABlyft #`.

### Turn it on

1. Open your project and go to **Settings → Project Settings**.
2. In the section **Debug Mode**, enable **Debug mode**.
3. Optionally enable **Restrict debug mode**. Then only browsers that opened a page with `?ablyft_show_debug=true` show
   the output. The setting is remembered for the browser session.
4. Save and wait for the [publication](https://docs.ablyft.com/developers/installation/publishing/).

> **Debug mode switches itself off:** Debug mode turns off automatically after 8 hours, and it turns off snippet caching while it is on. Do not leave it on
> for longer than needed, and use **Restrict debug mode** on a live website so that visitors do not see console output.

### What you see

With debug mode on, the console shows the initialization of the snippet (project, revision, storage) and then one line
per decision, indented by level:

* `Initiated PAGE "…"`: a page matched and became active
* `Initiated EXPERIMENT "…"`, `Initiated ENVIRONMENTS LOOKUP`, `Initiated AUDIENCES LOOKUP`: the experiment is being checked
* `ENVIRONMENT "…" is matching`, `AUDIENCES passed`, `Passed all exclusion groups`, `Exclusion group not passed`
* `EXPERIMENT "…" not running - User is excluded`: the visitor has been excluded before and stays excluded
* `Triggering BUCKETING Event`: the visitor was assigned to a variation
* `Applying JS`, `Applying VisualChanges`: variation code is run
* `Triggered GOAL "…"`: a goal fired
* `General Prerequisite Rules NOT met`, `Tracking Prerequisite Rules NOT met`, `Rated as Bot- Exiting`: the snippet stops or does not track

Errors in rules or in your JavaScript are shown as `ERROR on …` in red and are also dispatched as the browser event
`ablyftError`, see [Verify the integration](https://docs.ablyft.com/developers/debugging/verify-integration/#6-react-to-snippet-events-in-your-code).

## Preview mode

Preview mode lets you look at a variation of an experiment, even if the experiment is not running yet.

The easiest way is the **Preview** section on the experiment page. Select a **Variation to preview** and a
**URL to preview**, and open the link **Open preview directly in browser**. You can also copy the **Preview/Sharing URL**
or scan the QR code to preview on a phone. See [Preview & QA](https://docs.ablyft.com/guides/experiments/preview-and-qa/).

Behind the scenes, the preview link contains the URL parameters `ablyft_preview` and `ablyft_exclude_running`, see
[URL parameters](https://docs.ablyft.com/developers/reference/url-parameters/#ablyft_preview). The settings are kept for the browser session
(in `sessionStorage`), so you can click through your website without repeating the parameters.

Which experiments and checks apply during a preview is described in [Preview & QA](https://docs.ablyft.com/guides/experiments/preview-and-qa/#the-preview-box).
Triggered goals are not sent, but recorded locally, see below.

Check the state of preview mode in the console:

```js
ablyft.get('data').isPreview;        // true in preview mode
ablyft.get('preview_bucketing');     // { experimentId: variationId } from the preview parameter
ablyft.get('pingedGoals');           // goals that fired in preview mode: [{ id, time, value }]
```

> `pingedGoals` is filled in preview mode only. It lists goals that were triggered in the current browser session, which
> makes it a quick way to test goals without touching your results.

To leave preview mode, close the tab, or delete the session storage keys starting with `ablyft_` (`ablyft_preview_combs`,
`ablyft_exclude_running`).

## QA tool

The QA tool shows a panel on top of your website while you browse it in preview mode. It helps you check targeting and
goals.

1. Open the experiment and go to the **Preview** section.
2. Click **Open with quality assurance tool**.

This opens your page with the additional parameter `ablyft_qa_token=<token>`. The snippet loads the tool after
the page has loaded and keeps the token for the browser session.

> **Allow the QA tool in your site:** If your site uses a Content Security Policy, `app.ablyft.com` must be allowed in `connect-src` for the QA tool. See
> [Network and Content Security Policy](https://docs.ablyft.com/developers/installation/requirements/#network-and-content-security-policy).

## Force a variation

To show a specific variation to a visitor from your own code, for example in an automated test, push a `forceVariation`
event, see [`ablyft.push()`](https://docs.ablyft.com/developers/reference/javascript-api/push/#forcevariation) for the call and its limits.
Forced visitors are real participants, for a quick look at a variation use [preview mode](#preview-mode).

## Opt out for testers

To keep your own visits out of the data, open your website once with `?ablyft_opt_out=true`. See
[Opt out](https://docs.ablyft.com/developers/consent-and-security/storage-and-privacy/#opt-out).

## Live Log

The **Live Log** (**Project → Activity Log → Live Log**) shows the latest events that ABlyft received from the snippets
of your project. Columns, filters and how to read them are described in
[Check events in the Live Log](https://docs.ablyft.com/guides/goals-and-measurement/verify-measurement/#check-events-in-the-live-log).

> Goals triggered in [preview mode](#preview-mode) are not sent, so they do not appear in the Live Log.

## Next steps

* [Verify the integration](https://docs.ablyft.com/developers/debugging/verify-integration/)
* [Common issues](https://docs.ablyft.com/developers/debugging/common-issues/)
* [URL parameters](https://docs.ablyft.com/developers/reference/url-parameters/)

