# Page hits are not connected to correct leads

**URL:** https://forum.mautic.org/t/page-hits-are-not-connected-to-correct-leads/35785
**Category:** Product Support
**Created:** [June 3, 2025, 10:33am UTC](https://forum.mautic.org/t/page-hits-are-not-connected-to-correct-leads/35785 "2025-06-03T10:33:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![matejtarca](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/matejtarca/32/14075_2.png) [@matejtarca](https://forum.mautic.org/u/matejtarca)
#### Post date: [June 3, 2025, 10:33am UTC](https://forum.mautic.org/t/page-hits-are-not-connected-to-correct-leads/35785/1 "2025-06-03T10:33:22Z")

</div>

**Your software**  
My Mautic version is: 5.1.0  
My PHP version is: 8.1.29  
My Database type and version is: MySQL 5.7.44

**Your problem**

I need the ability to track users from our main website into Mautic. The main website is running NextJs so we use this piece of code added to every page for tracking via mautic script:

```auto
window.mt("send", "pageview", {
        path: pathname,
        email,
      })

```

The mt object is then appended to the page via GTM. I can see all the events from website inside mautic (in the `page_hits` table) but they are not connected to the correct contact even though the email in query is in Mautic as a contact. It seems Mautic creates a new lead, assigns the device ID and tracks it that way. How can I identify the contact in the tracking event so the page hits are correctly linked?

---

<div class="post-metadata">

### Author: ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)
#### Post date: [June 4, 2025, 5:40am UTC](https://forum.mautic.org/t/page-hits-are-not-connected-to-correct-leads/35785/2 "2025-06-04T05:40:40Z")

</div>

Any javascript errors? Are you running Mautic and your page on the same domain (I didn’t mean same subdomain)

---

<div class="post-metadata">

### Author: ![matejtarca](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/matejtarca/32/14075_2.png) [@matejtarca](https://forum.mautic.org/u/matejtarca)
#### Post date: [June 6, 2025, 11:01am UTC](https://forum.mautic.org/t/page-hits-are-not-connected-to-correct-leads/35785/3 "2025-06-06T11:01:44Z")

</div>

There are no javascript errors on the mautic tracking script side (I assume you meant there). And I see the request to `/mtc/event` endpoint going correctly with 200 response. The email is correctly set in the Request’s formdata object. Moreover I see the events in the Mautic `page_hits` DB table (along with the emails in `query` column) as mentioned previously.

Mautic instance is running on `mautic.company.com` and the site we want to track is running on `product.company.com` so yes it’s the same domain.
