# Page hits before contact form submission

**URL:** <https://forum.mautic.org/t/page-hits-before-contact-form-submission/17941>\
**Category:** Product Support\
**Created:** [January 27, 2021, 12:51pm UTC](https://forum.mautic.org/t/page-hits-before-contact-form-submission/17941 "2021-01-27T12:51:23Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![abracadabra.photogra](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/abracadabra.photogra/32/505_2.png) [@abracadabra.photogra](https://forum.mautic.org/u/abracadabra.photogra)\
**Post date:** [January 27, 2021, 12:51pm UTC](https://forum.mautic.org/t/page-hits-before-contact-form-submission/17941/1 "2021-01-27T12:51:23Z")

</div>

Hello,  
how is possibile to track contacts history before they submit a form?

For every contact I see "Contact created " event with the form submitted, but I’m not able to track the history of that contact when he was still anonymous…

thanks

---

<div class="post-metadata">

**Author:** ![mikew](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mikew/32/5156_2.png) [@mikew](https://forum.mautic.org/u/mikew)\
**Post date:** [January 27, 2021, 12:55pm UTC](https://forum.mautic.org/t/page-hits-before-contact-form-submission/17941/2 "2021-01-27T12:55:12Z")

</div>

The only way to do this is by matching up the IP from the anonymous contacts search. If the user comes in as a visitor he will be tracked anonymously and only his IP will be logged:

 ![Screen Shot 2021-01-27 at 14.54.20](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/f/fc7c883952f18a082cf5d9e02f6d282a906164fb.png)

---

<div class="post-metadata">

**Author:** ![abracadabra.photogra](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/abracadabra.photogra/32/505_2.png) [@abracadabra.photogra](https://forum.mautic.org/u/abracadabra.photogra)\
**Post date:** [January 27, 2021, 1:32pm UTC](https://forum.mautic.org/t/page-hits-before-contact-form-submission/17941/3 "2021-01-27T13:32:48Z")

</div>

Yes, I know, when a user comes as a visitor his IP is tracked, but how to merge automatically the history of the contact?

---

<div class="post-metadata">

**Author:** ![mikew](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mikew/32/5156_2.png) [@mikew](https://forum.mautic.org/u/mikew)\
**Post date:** [January 27, 2021, 2:01pm UTC](https://forum.mautic.org/t/page-hits-before-contact-form-submission/17941/4 "2021-01-27T14:01:34Z")

</div>

I am not sure how to do that through the UI. You may be able to do this via some scripting and mysql

---

<div class="post-metadata">

**Author:** ![abracadabra.photogra](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/abracadabra.photogra/32/505_2.png) [@abracadabra.photogra](https://forum.mautic.org/u/abracadabra.photogra)\
**Post date:** [January 27, 2021, 2:22pm UTC](https://forum.mautic.org/t/page-hits-before-contact-form-submission/17941/5 "2021-01-27T14:22:33Z")

</div>

I thought it was the standard behaviour, because in this way I lose all the info about page hits, source of acquisition, etc

---

<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:** [January 27, 2021, 6:04pm UTC](https://forum.mautic.org/t/page-hits-before-contact-form-submission/17941/6 "2021-01-27T18:04:05Z")

</div>

Hi! Is this a form filled out on a page or you are posting to a form via API?  
thx,  
J

---

<div class="post-metadata">

**Author:** ![abracadabra.photogra](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/abracadabra.photogra/32/505_2.png) [@abracadabra.photogra](https://forum.mautic.org/u/abracadabra.photogra)\
**Post date:** [January 27, 2021, 6:29pm UTC](https://forum.mautic.org/t/page-hits-before-contact-form-submission/17941/7 "2021-01-27T18:29:55Z")

</div>

Hi,  
The form is embedded in the page via javascript

---

<div class="post-metadata">

**Author:** ![abracadabra.photogra](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/abracadabra.photogra/32/505_2.png) [@abracadabra.photogra](https://forum.mautic.org/u/abracadabra.photogra)\
**Post date:** [January 28, 2021, 9:33am UTC](https://forum.mautic.org/t/page-hits-before-contact-form-submission/17941/8 "2021-01-28T09:33:17Z")

</div>

Normally how do you track contact source, if for example the lead cames from advertising, than visits some pages and then submits a form?

---

<div class="post-metadata">

**Author:** ![sfahrenkrog1](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/sfahrenkrog1/32/4583_2.png) [@sfahrenkrog1](https://forum.mautic.org/u/sfahrenkrog1)\
**Post date:** [January 28, 2021, 4:59pm UTC](https://forum.mautic.org/t/page-hits-before-contact-form-submission/17941/9 "2021-01-28T16:59:01Z")

</div>

Normally it goes like this:

If you have the tracking script in the website, mautic gives you a tracking cookie with the lead id.  
Mautic starts recording page hits to this lead id.

If the user submits a contact form, the information will be written to the already known lead id.

So you should see the pagehits the use have done before the form submit.

---

<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:** [January 28, 2021, 5:16pm UTC](https://forum.mautic.org/t/page-hits-before-contact-form-submission/17941/10 "2021-01-28T17:16:25Z")

</div>

Hi there,  
I have a similar issue - described in this thread:

> [@Tracking Code & Shopify Not Matching up to Contacts](https://forum.mautic.org/t/tracking-code-shopify-not-matching-up-to-contacts/16465/7):
>
> Hey @jordan_ryan , thank you so much for the answer. To make sure I understand it right: Someone visits shopify as an anonymous contact, creating a cookie. This person purchases something, so I fire the tracking pixel containing the email address on the thank you page The contact’s anonymous profile is now extended with the email = converted into a known contact? Joey

It seems, that anonymous contacts are not merged under certain circumstances as they supposed to. (logically…)  
For example as in the thread described:

1. anon user browse the page
2. email added by API (at this point it should not be merged)

- new contact created

1. welcome email sent out
2. email opened, cookie found, contact NOT merged with prev anon contact.

I would love to see if this is expected behaviour.

Joey

---

<div class="post-metadata">

**Author:** ![abracadabra.photogra](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/abracadabra.photogra/32/505_2.png) [@abracadabra.photogra](https://forum.mautic.org/u/abracadabra.photogra)\
**Post date:** [January 28, 2021, 5:48pm UTC](https://forum.mautic.org/t/page-hits-before-contact-form-submission/17941/11 "2021-01-28T17:48:20Z")

</div>

Yes I expect this behaviour,  
but this not works for me. Every contact starts with Contact created event (form submission). I don’t have any history before that

---

<div class="post-metadata">

**Author:** ![sfahrenkrog1](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/sfahrenkrog1/32/4583_2.png) [@sfahrenkrog1](https://forum.mautic.org/u/sfahrenkrog1)\
**Post date:** [January 28, 2021, 6:05pm UTC](https://forum.mautic.org/t/page-hits-before-contact-form-submission/17941/12 "2021-01-28T18:05:22Z")

</div>

This sounds like a third party cookie problem. Check if your mautic domain is on the same root domain like the website you embedded the mautic form.

For example:  
Mautic Domain under [m.domain.de](http://m.domain.de)  
Your domain with the mautic form: [domain.de](http://domain.de)

Is this the case?

---

<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:** [January 28, 2021, 8:34pm UTC](https://forum.mautic.org/t/page-hits-before-contact-form-submission/17941/13 "2021-01-28T20:34:18Z")

</div>

In my case we have the same domain w 2 subdomains:  
[shop.domain.com](http://shop.domain.com)  
[mautic.domain.com](http://mautic.domain.com)

---

<div class="post-metadata">

**Author:** ![sfahrenkrog1](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/sfahrenkrog1/32/4583_2.png) [@sfahrenkrog1](https://forum.mautic.org/u/sfahrenkrog1)\
**Post date:** [January 29, 2021, 6:42am UTC](https://forum.mautic.org/t/page-hits-before-contact-form-submission/17941/14 "2021-01-29T06:42:51Z")

</div>

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 browser he got the cookie from (in point 1) mautic should merge the lead.

---

<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:** [January 29, 2021, 8:51am UTC](https://forum.mautic.org/t/page-hits-before-contact-form-submission/17941/15 "2021-01-29T08:51:23Z")

</div>

Hi, I layed out my issue here.  
Person is browing on day 1 creating an anonimous contact. Then on day 5 he buys something, and a tracking pixel is fired up with the email value in it. (We get the email on the thank you page, so we can embed it into the pixel.) At the same time the shopify webhook pushes in the cart contents via API into Mautic using the email as unique identifier. What really happens is, that the tracking pixel is not connecting with the previous unknown visitor, but creating a new contact who already has the email and has never been on the website before.

I think THIS is how it should work:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/f/fb2ffd731387a964c7297bfccb1b6451ad04ff9f.png)

---

<div class="post-metadata">

**Author:** ![sfahrenkrog1](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/sfahrenkrog1/32/4583_2.png) [@sfahrenkrog1](https://forum.mautic.org/u/sfahrenkrog1)\
**Post date:** [January 29, 2021, 8:58am UTC](https://forum.mautic.org/t/page-hits-before-contact-form-submission/17941/16 "2021-01-29T08:58:26Z")

</div>

I would agree with you. This should work.

What happens if you launch the command:  
php app/console mautic:contacts:deduplicate

?

---

<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:** [January 29, 2021, 8:59am UTC](https://forum.mautic.org/t/page-hits-before-contact-form-submission/17941/17 "2021-01-29T08:59:26Z")

</div>

One more addition: these contacts have the same **mautic device id** , but not merged.  
What does the dedupe look at?  
J

---

<div class="post-metadata">

**Author:** ![sfahrenkrog1](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/sfahrenkrog1/32/4583_2.png) [@sfahrenkrog1](https://forum.mautic.org/u/sfahrenkrog1)\
**Post date:** [January 29, 2021, 9:03am UTC](https://forum.mautic.org/t/page-hits-before-contact-form-submission/17941/18 "2021-01-29T09:03:21Z")

</div>

I think the deduplication looks for the fields which are defined as unique values. Mautic default should be the email address.

---

<div class="post-metadata">

**Author:** ![sfahrenkrog1](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/sfahrenkrog1/32/4583_2.png) [@sfahrenkrog1](https://forum.mautic.org/u/sfahrenkrog1)\
**Post date:** [January 29, 2021, 9:04am UTC](https://forum.mautic.org/t/page-hits-before-contact-form-submission/17941/19 "2021-01-29T09:04:34Z")

</div>

Just to be sure: you got 2 leads both with the same email address?

---

<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:** [January 29, 2021, 9:14am UTC](https://forum.mautic.org/t/page-hits-before-contact-form-submission/17941/20 "2021-01-29T09:14:03Z")

</div>

No.  
I will have an anonymous contact with pre-purchase events, and a known contact with post purchase events and an email, both having the same Mautic Device ID.  
Does that change anything?

[Next page](https://forum.mautic.org/t/page-hits-before-contact-form-submission/17941.md?page=2)
