# API creates new contact instead of transform anonymous into known -?

**URL:** <https://forum.mautic.org/t/api-creates-new-contact-instead-of-transform-anonymous-into-known/13899>\
**Category:** Product Support\
**Created:** [April 14, 2020, 7:18pm UTC](https://forum.mautic.org/t/api-creates-new-contact-instead-of-transform-anonymous-into-known/13899 "2020-04-14T19:18:23Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![michaloptingo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/michaloptingo/32/422_2.png) [@michaloptingo](https://forum.mautic.org/u/michaloptingo)\
**Post date:** [April 14, 2020, 7:18pm UTC](https://forum.mautic.org/t/api-creates-new-contact-instead-of-transform-anonymous-into-known/13899/1 "2020-04-14T19:18:23Z")

</div>

**Your software**  
My Mautic version is: 2.16  
My PHP version is:7.2

**Your problem**  
My problem is:

I use Fluent Forms which has integration with Mautic and have the following problem:

- when Fluent Form is submitted I have new contact created in Mautic, nut this is completely new contact not linked with the anonymous contact which has been created automatically by Mautic
- as the result I still have anonymous contact where all visitor activity is tracked, and knows contact created with data from Fluent Form.

Any thoughts why? Is there different API to create new and to update anonymous with data?

Best regards,

Michal

---

<div class="post-metadata">

**Author:** ![raminnaimi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/raminnaimi/32/412_2.png) [@raminnaimi](https://forum.mautic.org/u/raminnaimi)\
**Post date:** [June 16, 2020, 4:50pm UTC](https://forum.mautic.org/t/api-creates-new-contact-instead-of-transform-anonymous-into-known/13899/2 "2020-06-16T16:50:25Z")

</div>

I have ran into this as well and I can’t figure out why the transition from anonymous to known contact isn’t working properly.  
I am also interested in whomever can provide insight into this.

---

<div class="post-metadata">

**Author:** ![adirbnology](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/adirbnology/32/494_2.png) [@adirbnology](https://forum.mautic.org/u/adirbnology)\
**Post date:** [July 9, 2020, 7:51pm UTC](https://forum.mautic.org/t/api-creates-new-contact-instead-of-transform-anonymous-into-known/13899/3 "2020-07-09T19:51:27Z")

</div>

Same here.

I have tried the following:

1. Open incognito on my website login page and found mautic contact id in the cookie.
2. On mautic New contact has been created with this id and page hit event.
3. Made login in my website and on the dashboard page fired pixel with email value of existing contact.

Result :  
Page hit event of the dashboard has been added to the contact that was not anonymous.

Anonymous contact left as is.

Expected behavior:  
Merging anonymous contact with the existing one

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [July 9, 2020, 9:49pm UTC](https://forum.mautic.org/t/api-creates-new-contact-instead-of-transform-anonymous-into-known/13899/4 "2020-07-09T21:49:29Z")

</div>

What version of Mautic? I tested a PR that fixed this behaviour only recently.

---

<div class="post-metadata">

**Author:** ![adirbnology](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/adirbnology/32/494_2.png) [@adirbnology](https://forum.mautic.org/u/adirbnology)\
**Post date:** [July 9, 2020, 10:02pm UTC](https://forum.mautic.org/t/api-creates-new-contact-instead-of-transform-anonymous-into-known/13899/5 "2020-07-09T22:02:34Z")

</div>

Actually its 3.0, so maybe its a bug?

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [July 9, 2020, 10:17pm UTC](https://forum.mautic.org/t/api-creates-new-contact-instead-of-transform-anonymous-into-known/13899/6 "2020-07-09T22:17:20Z")

</div>

Try updating to 3.0.1? Here is the PR I was thinking of, does that sound like the problem?

> <https://github.com/mautic/mautic/pull/8836>

---

<div class="post-metadata">

**Author:** ![adirbnology](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/adirbnology/32/494_2.png) [@adirbnology](https://forum.mautic.org/u/adirbnology)\
**Post date:** [July 9, 2020, 10:41pm UTC](https://forum.mautic.org/t/api-creates-new-contact-instead-of-transform-anonymous-into-known/13899/7 "2020-07-09T22:41:14Z")

</div>

My problem is that lead doesnt get merged. I was expecting that sending the email from the pixel will merge the leads. Maybe im doing something wrong here? On the attached doc one of the steps was merging the contact manually. And im expecting this action to take place automatically as i sent from my pixel while cookie contact id was anonymous , an email that exists in other lead. Do u think updating to 3.01 will solve this?

---

<div class="post-metadata">

**Author:** ![adirbnology](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/adirbnology/32/494_2.png) [@adirbnology](https://forum.mautic.org/u/adirbnology)\
**Post date:** [July 30, 2020, 9:40am UTC](https://forum.mautic.org/t/api-creates-new-contact-instead-of-transform-anonymous-into-known/13899/8 "2020-07-30T09:40:50Z")

</div>

i have updated the mautic last release (3.02) and still same behavior.  
when i update anonymous contact with existing email no merge action is taking place and i just have additional contact with the same email.

---

<div class="post-metadata">

**Author:** ![adirbnology](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/adirbnology/32/494_2.png) [@adirbnology](https://forum.mautic.org/u/adirbnology)\
**Post date:** [July 30, 2020, 12:30pm UTC](https://forum.mautic.org/t/api-creates-new-contact-instead-of-transform-anonymous-into-known/13899/9 "2020-07-30T12:30:00Z")

</div>

as per @silavapi request please find steps to reproduce :

1. choose some existing contact from mautic  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/1/13542601ebac39e8c42e9d4e67b42fc7606adf50.png)

2. go to anonymous contacts and open one of them.  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/a/ae991e3edbac481c6c0d7924b6031677a9deb92f.png)

3. edit the contact  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/f/fe2288f8b9d12f4614dc4aadf12517f78d4bd3b6.png)

4. paste the chosen email from the first step. u could find the mautic recognize this email. save the update.  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/f/fd4bb3e464183fd3217b3905c6ef8b8e97d444ce.png)

5. go to contacts. u will find that the anonymous contact has been updated and now there are 2 contacts with the same unique key.

u might ask on what scenario i need to recognize anonymous contact manually, so the answer for that is that if user is using new device and not recognized when he logged in to my platform i send page view with his email but the outcome is same as above

---

<div class="post-metadata">

**Author:** ![maxemojo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/maxemojo/32/471_2.png) [@maxemojo](https://forum.mautic.org/u/maxemojo)\
**Post date:** [April 13, 2021, 3:03pm UTC](https://forum.mautic.org/t/api-creates-new-contact-instead-of-transform-anonymous-into-known/13899/10 "2021-04-13T15:03:11Z")

</div>

Was going to ask if this was resolved.  
Then I thought let me try something first:  
Run php bin/console mautic:contacts:deduplicate  
That helped.  
Leaving it here on an old post in case somebody comes across it.

---

<div class="post-metadata">

**Author:** ![imihandstand](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/imihandstand/32/1499_2.png) [@imihandstand](https://forum.mautic.org/u/imihandstand)\
**Post date:** [April 19, 2021, 7:50am UTC](https://forum.mautic.org/t/api-creates-new-contact-instead-of-transform-anonymous-into-known/13899/11 "2021-04-19T07:50:34Z")

</div>

> [@maxemojo](#):
>
> Run php bin/console mautic:contacts:deduplicate

Unfortunately this did nothing for me - 0 changes. But it checked just identified contacts (so the ones with an email-address). But the poster has the issue (just like me) that identified contacts won’t get attached to the anonym contact.

---

<div class="post-metadata">

**Author:** ![olimits7](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/olimits7/32/3071_2.png) [@olimits7](https://forum.mautic.org/u/olimits7)\
**Post date:** [April 18, 2024, 2:14am UTC](https://forum.mautic.org/t/api-creates-new-contact-instead-of-transform-anonymous-into-known/13899/12 "2024-04-18T02:14:30Z")

</div>

Has anyone been able to figure how to resolve this issue? I’m facing the same issue when I use the API to add a contact to Mautic. It ends up creating a new contact ID instead of using existing anonymous cookie contact ID.

---

<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:** [May 5, 2024, 4:17pm UTC](https://forum.mautic.org/t/api-creates-new-contact-instead-of-transform-anonymous-into-known/13899/13 "2024-05-05T16:17:41Z")

</div>

This is why it happens:

> [@Page hits before contact form submission](https://forum.mautic.org/t/page-hits-before-contact-form-submission/17941/14):
>
> Hi Joey Sorry missed your question if this is expected behaviour. Normally it should merge the contact but ONLY if the email is opened in the same browser he got the cookie from point 1. In Point 1. the user should get a cookie with a lead id. In Point 2 you create another lead id with the email. In point 3. you send a welcome email (make sure you enabled track\_by\_tracking\_url in the config) which got the lead id encoded in the email links. If the visitor opens the email link in the same br…

---

<div class="post-metadata">

**Author:** ![olimits7](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/olimits7/32/3071_2.png) [@olimits7](https://forum.mautic.org/u/olimits7)\
**Post date:** [May 6, 2024, 3:01am UTC](https://forum.mautic.org/t/api-creates-new-contact-instead-of-transform-anonymous-into-known/13899/14 "2024-05-06T03:01:19Z")

</div>

My issue is even after creating the contact in Mautic via API, if I then log in with this email address that was used to create the contact via API it still doesn’t track “page hits” under the email address contact ID.

For example, if I go to my website now I’ll see mtc\_id 186684; then I log in to the website using the email address that the contact was created in Mautic via API and the only way I can see “page hits” is under Anonoymous.

My email address that is listed in Mautic under mtc\_id 19705 doesn’t seem to merge with the mtc\_id 186684 in the browser.

---

<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:** [May 6, 2024, 12:01pm UTC](https://forum.mautic.org/t/api-creates-new-contact-instead-of-transform-anonymous-into-known/13899/15 "2024-05-06T12:01:34Z")

</div>

> [@olimits7](#):
>
> I go to my website

“I go to my website” - remember, you always need to test as non-admin user in another browser.

---

<div class="post-metadata">

**Author:** ![olimits7](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/olimits7/32/3071_2.png) [@olimits7](https://forum.mautic.org/u/olimits7)\
**Post date:** [May 6, 2024, 3:00pm UTC](https://forum.mautic.org/t/api-creates-new-contact-instead-of-transform-anonymous-into-known/13899/16 "2024-05-06T15:00:25Z")

</div>

Yes, I always open up an incognito browser window when I’m testing this but still the same issue.

---

<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:** [May 6, 2024, 3:11pm UTC](https://forum.mautic.org/t/api-creates-new-contact-instead-of-transform-anonymous-into-known/13899/17 "2024-05-06T15:11:11Z")

</div>

Do you have your mtc.js script and your website on the same domain?

---

<div class="post-metadata">

**Author:** ![olimits7](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/olimits7/32/3071_2.png) [@olimits7](https://forum.mautic.org/u/olimits7)\
**Post date:** [May 6, 2024, 4:26pm UTC](https://forum.mautic.org/t/api-creates-new-contact-instead-of-transform-anonymous-into-known/13899/18 "2024-05-06T16:26:37Z")

</div>

I have mtc.js script under “[domain.com](http://domain.com)” and I have Mautic installed under “[mautic.domain.com](http://mautic.domain.com)”.

---

<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:** [May 7, 2024, 5:34am UTC](https://forum.mautic.org/t/api-creates-new-contact-instead-of-transform-anonymous-into-known/13899/19 "2024-05-07T05:34:22Z")

</div>

Okay, that is fine, they are under the same domain.  
Do you see any javascript errors?

---

<div class="post-metadata">

**Author:** ![olimits7](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/olimits7/32/3071_2.png) [@olimits7](https://forum.mautic.org/u/olimits7)\
**Post date:** [May 7, 2024, 12:20pm UTC](https://forum.mautic.org/t/api-creates-new-contact-instead-of-transform-anonymous-into-known/13899/20 "2024-05-07T12:20:41Z")

</div>

Where should I look for javascript errors? Under my server log files, or Mautic log files (Settings \> System Info \> Log)? Or under browser inspect?

Should I be checking for errors under my "**[domain.com](http://domain.com)** website where I have the mtc.js script installed?
