Your software
My Mautic version is: 4.2.2
My PHP version is: 7.4
Your problem
My problem is:
I have done this hundred of times and it is working on so many sites, however I have one Wordpress site that I have a Mautic Form integrated using the javascript provided and I can see when the user hits the page, fills out the form, but does not merge this with the anonymous user.
A little bit more information and a question here.
First the question. If a site is sitting behind Cloudflare or Mautic is sitting behind Cloudflare could this have an affect.
I did an experiment, I went to another Wordpress installation connected the exact same way with Mautic and did the exercise of visiting in incognito, then filling out a contact-us form and seeing that the anonymous user is converted into the new user details - and this worked.
I then went to the problematic Wordpress instance and changed the plugin to track from the ams of the working Wordpress site, then went to the problematic Wordpress site updated all the new information and tested it.
After a days investigation I think I am confident enough to say that this is a server issue with Cloudflare. Depending on the web server you are using you will need to modify it so that it can catch the real ip of the user and not Cloudflare IP.
maybe someone can help she some light on this, I am checking the access logs and see that my own IP is actually being logged at each stage, so I am wondering if this show real ip needs to be configured on the Wordpress site
99.999.99.99 - - [01/Jun/2022:18:37:53 +0000] "GET /index.php/form/generate.js?id=2 HTTP/1.1" 200 6971 "https://www.wordpress-site.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36"
99.999.99.99 - - [01/Jun/2022:18:37:53 +0000] "GET /index.php/mtc.js HTTP/1.1" 200 100698 "https://www.wordpress-site.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36"
99.999.99.99 - - [01/Jun/2022:18:37:54 +0000] "GET /dwc/firstnamegreeting?page_title=Test%20Contact%20-%20Knup%20Sports&page_language=en-US&preferred_locale=en_US&page_referrer=&page_url=https%3A%2F%2Fwww.knupsports.com%2Ftest-contact%2F&counter=0&timezone_offset=-180&resolution=1920x1080&platform=MacOS&do_not_track=false&timezone=Asia%2FJerusalem&mautic_device_id=1eefceq3lwz0mwdf8htxmqr HTTP/1.1" 204 0 "https://www.wordpress-site.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36"
99.999.99.99 - - [01/Jun/2022:18:37:54 +0000] "POST /mtc/event HTTP/1.1" 200 122 "https://www.wordpress-site.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36"
99.999.99.99 - - [01/Jun/2022:18:38:13 +0000] "POST /form/submit?formId=2 HTTP/1.1" 200 254 "https://www.wordpress-site.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36"