# PageView and Click ID

> Learn how AnyTrack tracks page views automatically and how to generate the atclid Click ID variable for use in forms, links, or CRM integrations. Covers the atclid command, callback syntax, Google Tag Manager setup, and the atclidToUrl method for appending the Click ID to page URLs.

<Prerequisites
  title="Before you begin"
  items={[
    { label: "The Tracking Tag is installed on your website", done: true },
    { label: "You have an active AnyTrack property", done: true },
    { label: "You are comfortable editing JavaScript on your site (for advanced commands)", done: true },
  ]}
/>

**PageView tracking** is the automatic capture of every page load on your website by the AnyTrack [Tracking Tag](/docs/install-anytrack-tag), generating an `atclid` Click ID for each session that ties subsequent events back to the originating ad click. It enriches each page load with UTM parameters, traffic source, and session data so AnyTrack can attribute conversions to the campaigns that drove them.

`PageView` events build a complete picture of the customer journey. Ad platforms use this journey data — combined with [Event Attributes](/docs/event-attributes) and AnyTrack's [standard events](/docs/standard-events) — to understand what content and messaging drives conversions.

> 📘 **Note**
>
> PageView tracking is available on all plans, including Free.

> ❗ **Important**
>
> The `atclid` and `atclidToUrl` commands below require JavaScript knowledge. If you are not comfortable with code, share this guide with your developer.

## Generate the `atclid` Variable

The `atclid` command returns a Click ID generated from the current user session, without relating it to any specific event. Use this when you need the Click ID value for custom integrations:

```javascript
var atclid = AnyTrack('atclid');
```

This command only works after the Tracking Tag has loaded. To ensure the Tracking Tag is ready, wrap the call in a callback:

```javascript
AnyTrack(function () {
    var atclid = AnyTrack('atclid');
    // Use atclid value here
});
```

## Generate `atclid` in Google Tag Manager

Create a Custom JavaScript Variable in GTM with the following code:

```javascript
function () {
    return AnyTrack('atclid');
}
```

The `atclid` value is then available as a variable in any tag within your GTM container.

## Append Click ID to Page URL

Sometimes you need to append the AnyTrack Click ID on page load. For example, when a form builder does not let you customize hidden field values, or has no hidden fields at all but can grab URL parameters.

```javascript
<script>
  AnyTrack(function() {
    AnyTrack('atclidToUrl', 'custom_query_parameter');
  });
</script>
```

Replace `custom_query_parameter` with the parameter name your form expects. The default parameter name is `_atid` if no custom name is provided.

For a complete guide on URL-based Click ID passing, see [Single Page Tracking](/docs/single-page-tracking). To pass your own identifier as the AnyTrack Click ID, see [External ID as Click ID](/docs/external-id-as-click-id). If a conversion is missing its Click ID, see the [Integration Event Log](/docs/integration-event-log) for troubleshooting.

***

<FaqAccordion
  title="FAQ and Troubleshooting"
  items={[
    {
      question: "Do I need to set up PageView tracking manually?",
      answer: "No. The Tracking Tag tracks page views automatically once installed. The commands on this page are only needed when you want to access the Click ID value programmatically for custom integrations."
    },
    {
      question: "What is the difference between atclid and the Click ID from a trigger event?",
      answer: "The atclid command generates a Page Click ID from the current session without tying it to a specific event. The trigger command generates a Click ID that is associated with a specific event like Lead or Purchase as well as element. Both return valid Click IDs that can be used for server-side tracking."
    },
    {
      question: "When should I use atclidToUrl instead of a hidden form field?",
      answer: "Use atclidToUrl when your form builder does not support hidden field injection but can capture values from URL parameters. See the Single Page Tracking article for the full setup guide."
    }
  ]}
/>
