# Pixel count views on data only next.js page

**URL:** <https://forum.builder.io/t/pixel-count-views-on-data-only-next-js-page/6259>\
**Category:** Technical Questions\
**Tags:** page-views, api, nextjs\
**Created:** [August 26, 2024, 2:24pm UTC](https://forum.builder.io/t/pixel-count-views-on-data-only-next-js-page/6259 "2024-08-26T14:24:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikola](https://avatars.discourse-cdn.com/v4/letter/n/a88e57/32.png) [@nikola](https://forum.builder.io/u/nikola)\
**Post date:** [August 26, 2024, 2:24pm UTC](https://forum.builder.io/t/pixel-count-views-on-data-only-next-js-page/6259/1 "2024-08-26T14:24:02Z")

</div>

Hello,

I am having issues where I see a bunch of requests sent to the [builder.io](http://builder.io) pixel with the event that is what I believe is tracking for a page view. Screenshots provided.

Why is pixel tracking anything on a page that displays only data models that are queried via content API?

I am using only content API for that page and not the “RenderBuilderContent” component.

I am using next.js with an app router and a layout that is querying “footer”, “header” and “navigation” models, all of which are data models. Additionally, I have filtering and sorting that are calling only the data portion of the model and on every URL change (URL params are used for filtering and sorting) a call is made.

**Builder public API key**  
197884cda72d4f8780e848822de859eb

**Screenshots or video link**

 ![Screenshot 2024-08-26 at 16.20.25](https://us1.discourse-cdn.com/flex020/uploads/builder/original/2X/b/bc27f9ad6599c0ebb6fae46a92699fb8a72b4f43.png)

**Code stack you are integrating Builder with**  
NextJS app router

---

<div class="post-metadata">

**Author:** ![manish-sharma](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@manish-sharma](https://forum.builder.io/u/manish-sharma)\
**Post date:** [August 27, 2024, 10:49am UTC](https://forum.builder.io/t/pixel-count-views-on-data-only-next-js-page/6259/2 "2024-08-27T10:49:25Z")

</div>

Hello @nikola,

Welcome to the [Builder.io](http://Builder.io) forum post.

We have thoroughly investigated the issue on our end, and it seems that it could be an integration-related issue. The [Data models](https://www.builder.io/c/docs/models-data) in Builder are not included in visual views and are solely subject to bandwidth metering. As a result, these models should not trigger additional pixel tracking for visual views.

Please carefully review if any page sections inadvertently utilize visual components or if content queries are causing implicit visual views. It is important to ensure that all content queries are specifically for data models and are rendered correctly.

In order for us to provide further assistance, we kindly ask for more detailed insights into your data model integration.

Thank you.

---

<div class="post-metadata">

**Author:** ![manish-sharma](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@manish-sharma](https://forum.builder.io/u/manish-sharma)\
**Post date:** [August 28, 2024, 5:45pm UTC](https://forum.builder.io/t/pixel-count-views-on-data-only-next-js-page/6259/3 "2024-08-28T17:45:37Z")

</div>

Hello @nikola,

I hope this message finds you well. Just checking in to see if you’re still dealing with any problems related to pixel tracking and data model integration. If you are, please provide us with the integration code or a minimal reproducible case so that we can offer you further assistance.

Thank you.

---

<div class="post-metadata">

**Author:** ![nikola](https://avatars.discourse-cdn.com/v4/letter/n/a88e57/32.png) [@nikola](https://forum.builder.io/u/nikola)\
**Post date:** [September 2, 2024, 7:57am UTC](https://forum.builder.io/t/pixel-count-views-on-data-only-next-js-page/6259/4 "2024-09-02T07:57:21Z")

</div>

Hello @manish-sharma, let me introduce you to our use case with some updated context.

We are using the next.js app and on the search page (search.tsx) we are calling:

**builder.getAll(‘search-settings’, options)** - ‘search-settings’ is a data model  
**builder.getAll(‘content-page’, options)** - ‘content-page’ is a page model and here we are using ‘prerender: false’ in order to return JSON and returning only a few fields in order to build search filters.

in layout.tsx that is the wrapper for this page we are using:  
**builder.get(‘navigation’)** - ‘navigation’ is a data model  
**builder.get(‘footer’)** - ‘footer’ is a data model  
**builder.get(‘utility-bar’)** - ‘utility-bar’ is a data model

and when changing filters on that page we are changing query params and calling our API that is making a call:  
**builder.getAll(‘content-page’, options)** - ‘content-page’ is a page model and here we are using ‘prerender: false’, here we are retrieving results.

Each query param change is calling tracking pixel with the page counter increased. Is that supposed to happen with our setup?

We are not using ‘ **BuilderComponent** ’ anywhere on those pages I say that because I think that it is responsible for increasing page views. We are using it on some other pages. Also all of those action are on server side portion of next.js app. We are using `edge` runtime because we are hosting our app on the Cloudflare Pages.

---

<div class="post-metadata">

**Author:** ![nikola](https://avatars.discourse-cdn.com/v4/letter/n/a88e57/32.png) [@nikola](https://forum.builder.io/u/nikola)\
**Post date:** [September 3, 2024, 8:29am UTC](https://forum.builder.io/t/pixel-count-views-on-data-only-next-js-page/6259/5 "2024-09-03T08:29:49Z")

</div>

Additionally,

when we query a page we don’t have in [builder.io](http://builder.io) and show a 404 page we get a tracking pixel called.

Initially, we are checking if a page model with urlPath is provided by **builder.get** ; if not, we are rendering our own 404 page.

Again, that page uses a layout that is retrieving navigation, footer, utility-bar but they are all data models.

Why are we getting tracking pixels there? Are tracking pixels counting API calls? From the documentation, I can see that the visual view should only be tracked when a single Page contains content entries from the [builder.io](http://builder.io) but what is the case if it does not return results like 404?

 ![Screenshot 2024-09-03 at 10.23.02](https://us1.discourse-cdn.com/flex020/uploads/builder/original/2X/e/e0a5aa62373cfbc5a05ade04b47843b97746390d.png)

---

<div class="post-metadata">

**Author:** ![manish-sharma](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@manish-sharma](https://forum.builder.io/u/manish-sharma)\
**Post date:** [September 3, 2024, 4:19pm UTC](https://forum.builder.io/t/pixel-count-views-on-data-only-next-js-page/6259/6 "2024-09-03T16:19:43Z")

</div>

Hello @nikola,

Again, querying data models like `navigation` , `footer` , and `utility bar` should not trigger tracking pixels as they are not considered visual content models.

When querying a page model that results in a 404 (i.e., the page does not exist), [Builder.io](http://Builder.io) tracking pixels can still be triggered. This is primarily due to how the SDK, alongside the server-side logic, handles the requests and responses.

To prevent the tracking pixels from firing when rendering a 404 page, you can try and implement the following steps:

1. Implement a check to disable tracking specifically when rendering a 404 page:

```auto
import { builder } from '@builder.io/sdk';

// Replace with your Public API Key
builder.init(YOUR_API_KEY);

export async function getPageContent(urlPath) {
  const content = await builder.get('page', {
    userAttributes: {
      urlPath: urlPath,
    },
    prerender: false,
  }).toPromise();

  if (!content) {
    builder.canTrack = false; // Disable tracking for 404 pages
    return null;
  }
  
  return content;
}

```

1. **Modify Fetch Function** : Use a custom function to fetch the builder content while ensuring tracking is disabled if the content does not exist:

```auto
async function fetchWithConditionalTracking(model, options) {
 builder.canTrack = false; // Disable tracking
 const data = await builder.get(model, options);

 if (data) {
   builder.canTrack = true; // Enable tracking if data exists
 }

 return data;
}

// Example usage in getStaticProps or similar function
export async function getStaticProps({ params }) {
 const pageContent = await fetchWithConditionalTracking('page', {
   userAttributes: {
     urlPath: '/' + (params?.page?.join('/') || ''),
   },
   prerender: false,
 });

 return {
   props: {
     page: pageContent ? pageContent : null,
   },
   revalidate: 5,
 };
}

```

1. **Handling in Layout and Query Changes** : Ensure that any dynamic layout or query changes also respect this tracking behavior:

```auto
// Example API call handling with conditional tracking
builder.getAll('content-page', { ...options, prerender: false }).then(results => {
  if (!results.length) {
    builder.canTrack = false; // Disable tracking if no results found
  }
  // Handle results
});

```

Let us know how the above suggestions work for you!

Thanks,

---

<div class="post-metadata">

**Author:** ![nikola](https://avatars.discourse-cdn.com/v4/letter/n/a88e57/32.png) [@nikola](https://forum.builder.io/u/nikola)\
**Post date:** [September 4, 2024, 12:26pm UTC](https://forum.builder.io/t/pixel-count-views-on-data-only-next-js-page/6259/7 "2024-09-04T12:26:55Z")

</div>

Hello @manish-sharma, thanks for the response and suggestion.

I have put **`builder.canTrack = false`** after the SDK calls if I don’t receive results and I can still see the same kind of tracking requests to **`api2.amplitude.com`** with events that contain something like **`event_type: "[Amplitude] Page Viewed"`**.

I went even further and put the same code after every **`builder.init`** I have in my codebase, but nothing happens, we have calls again.

The real question is if those calls are increasing page views or if we don’t need to care about that?

I ask that because in [builder.io](http://builder.io) dashboard I don’t see any page views for my search page nor any 404 page I hint which is normal. I see only counts for the pages registered as a page model in [builder.io](http://builder.io). My concern was whether those numbers would increase in any way because of those calls to **`api2.amplitude.com`** , even if we are not rendering content from the page model.

Thanks

 ![Screenshot 2024-09-04 at 14.15.20](https://us1.discourse-cdn.com/flex020/uploads/builder/original/2X/c/c5a8a1bd7119195e94bda3764f71d4744ebb7479.png)  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/builder/original/2X/c/c6f42ff86d1b4bd5856c5740b777155fc406bc3e.png)

---

<div class="post-metadata">

**Author:** ![manish-sharma](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@manish-sharma](https://forum.builder.io/u/manish-sharma)\
**Post date:** [September 4, 2024, 6:05pm UTC](https://forum.builder.io/t/pixel-count-views-on-data-only-next-js-page/6259/8 "2024-09-04T18:05:37Z")

</div>

Hello @nikola,

The tracking calls you see to `api2.amplitude.com` do not affect the page view tracking in [Builder.io](http://Builder.io) and thus won’t impact your [Builder.io](http://Builder.io) dashboard statistics.

If you see requests to `api2.amplitude.com` it indicates custom Amplitude event tracking set in your implementation. These events are **separate from the default tracking [Builder.io](http://Builder.io) conducts**.

Builder analytics are captured by sending a request to [https://cdn.builder.io/api/v1/track](https://cdn.builder.io/api/v1/track)

 ![Screenshot 2024-09-04 at 11.31.09 PM](https://us1.discourse-cdn.com/flex020/uploads/builder/original/2X/e/e844724c5acf2785b94c2d545c5980a58652db1f.png)  
 ![Screenshot 2024-09-04 at 11.30.59 PM](https://us1.discourse-cdn.com/flex020/uploads/builder/original/2X/d/d7b66c84399433f03ff30278bb1d1e6dcd37801f.png)

To know more you can refer to the below links

> **[Understanding Visual Views (Pageviews) - Builder.io](https://www.builder.io/c/docs/visualviews)**
>
> Learn what Visual Views (also known as Pageviews) are, what counts toward your Visual Views, what doesn't, and how they are tracked.

> **[Impressions Compared to Visual Views - Builder.io](https://www.builder.io/c/docs/impressions-and-visualviews)**
>
> Learn the difference between Impressions and Visual Views in Builder. Understand tracking pixels and crawler impact on metrics.

Hope this helps!

Thanks,
