# Assign events to existing contacts from mtc.js

**URL:** <https://forum.mautic.org/t/assign-events-to-existing-contacts-from-mtc-js/16882>\
**Category:** Product Support\
**Tags:** community, event\
**Created:** [November 5, 2020, 6:07pm UTC](https://forum.mautic.org/t/assign-events-to-existing-contacts-from-mtc-js/16882 "2020-11-05T18:07:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![programwar](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/programwar/32/3827_2.png) [@programwar](https://forum.mautic.org/u/programwar)\
**Post date:** [November 5, 2020, 6:07pm UTC](https://forum.mautic.org/t/assign-events-to-existing-contacts-from-mtc-js/16882/1 "2020-11-05T18:07:26Z")

</div>

**Your software**  
My Mautic version is: 3.1  
My PHP version is: 7.3.20-1  
My Database type and version is: mysql Ver 15.1 Distrib 10.5.4-MariaDB

**Your problem**  
My problem is:

I try assign and event to an existing contact, but the event is attached to an anonymous contact. My code is:

```
<script>
    (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', 'https://xxxxxx.com/mtc.js', 'mt');

    mt('send', 'pageview', { id: [existing_id], email: '[existing_email]', name: 'XXXX', surname: 'XXX', phone: 'xxxx });
</script>	

```

In fact, I’m able to see all these fields on the event.

**These errors are showing in the log:**

No error in the log.

**Steps I have tried to fix the problem:**

1. Load a page with attached code.
2. Go to Contacts view in Mautic.

---

<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:** [November 6, 2020, 6:42am UTC](https://forum.mautic.org/t/assign-events-to-existing-contacts-from-mtc-js/16882/2 "2020-11-06T06:42:18Z")

</div>

Just an idea:  
I had to fiddle with this when I was doing similar things.  
(This is in custom fields.)  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/6/68c393252116b1b1f191b08c06970635f05ea48d.png)

Good luck!

---

<div class="post-metadata">

**Author:** ![programwar](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/programwar/32/3827_2.png) [@programwar](https://forum.mautic.org/u/programwar)\
**Post date:** [November 6, 2020, 3:20pm UTC](https://forum.mautic.org/t/assign-events-to-existing-contacts-from-mtc-js/16882/3 "2020-11-06T15:20:43Z")

</div>

Thank you @joeyk!

This was just what I’m missing 🙂
