# Tracking site which one can log out from

**URL:** <https://forum.mautic.org/t/tracking-site-which-one-can-log-out-from/4765>\
**Category:** Product Support\
**Created:** [August 5, 2016, 3:09pm UTC](https://forum.mautic.org/t/tracking-site-which-one-can-log-out-from/4765 "2016-08-05T15:09:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![honzakuchar](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/honzakuchar/32/57_2.png) [@honzakuchar](https://forum.mautic.org/u/honzakuchar)\
**Post date:** [August 5, 2016, 3:09pm UTC](https://forum.mautic.org/t/tracking-site-which-one-can-log-out-from/4765/1 "2016-08-05T15:09:14Z")

</div>

Hello! Thank you for maintaining Mautic!  
  
  
  
We have application where users can log in and out. Mautic tracking works this way:

- User hits the page - tracking code is loaded and we provide user ID 1 (which is marked as unique)  
- Mautic creates anonymous lead and assignes ID:1 and find that ID 1 is already present and merges these two leads together  
  
(everything is great till now!)  
- user logs out  
- logs as another user (without closing browser; mautic cookies were not flushed; Mautic sees this as one session)  
- we send ID:2 into Mautic tracking code  
- mautic finds that it knows this contact with ID:2 and merges lead ID:2 with lead ID:1 - **Whops! We have lost one contact.**  
  
  
  
**Is this bug? Or are we using tracking code in wrong way?**  

Code:

  
Problem is that Mautic tracks user by cookie/session. When it does not know which lead is it - it creates new lead. But there is no way to say in tracking code:

Quote:

Hey Mautic, from now cookie:abcd is lead with ID:1.

  
Is there any what how to do this?

---

<div class="post-metadata">

**Author:** ![honzakuchar](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/honzakuchar/32/57_2.png) [@honzakuchar](https://forum.mautic.org/u/honzakuchar)\
**Post date:** [August 5, 2016, 3:09pm UTC](https://forum.mautic.org/t/tracking-site-which-one-can-log-out-from/4765/2 "2016-08-05T15:09:14Z")

</div>

Hello! Thank you for maintaining Mautic!

We have application where users can log in and out. Mautic tracking works this way:

- User hits the page - tracking code is loaded and we provide user ID 1 (which is marked as unique)
- Mautic creates anonymous lead and assignes ID:1 and find that ID 1 is already present and merges these two leads together  
(everything is great till now!)
- user logs out
- logs as another user (without closing browser; mautic cookies were not flushed; Mautic sees this as one session)
- we send ID:2 into Mautic tracking code
- mautic finds that it knows this contact with ID:2 and merges lead ID:2 with lead ID:1 - Whops! We have lost one contact.

Is this bug? Or are we using tracking code in wrong way?

```auto
<script n:if="$user->loggedIn">
	(function(w,d,t,u,n,a,m){ w['MauticTrackingObject']=n;
		w[n]=w[n]||function(){ (w[n].q=w[n].q||[]).push(arguments)},a=d.createElement(t),
				m=d.getElementsByTagName(t)[0];a.async=1;a.src=u;m.parentNode.insertBefore(a,m)
	})(window,document,'script','http://localhost:8000/mtc.js','mt');

	mt('send', 'pageview', { uuid: {$user->identity->getId()->toString()}});

</script>
```

Problem is that Mautic tracks user by cookie/session. When it does not know which lead is it - it creates new lead. But there is no way to say in tracking code:

> [@](#):
>
> Hey Mautic, from now cookie:abcd is lead with ID:1.

Is there any what how to do this?

---

<div class="post-metadata">

**Author:** ![namratasaun](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/namratasaun/32/2801_2.png) [@namratasaun](https://forum.mautic.org/u/namratasaun)\
**Post date:** [December 10, 2020, 12:45pm UTC](https://forum.mautic.org/t/tracking-site-which-one-can-log-out-from/4765/3 "2020-12-10T12:45:31Z")

</div>

any resolution to this?  
having same problem @honzakuchar
