Contact tracking in our application: nothing registered on Contact

Your software
My Mautic version is: 4.4.5
My PHP version is: 7.4
My Database type and version is: Mysql

Your problem
My problem is:
When trying to register a pageview in our webapplication (with a created contact) through javascript. Nothing is added to the Contact’s record.

Steps I have tried to fix the problem:

1/ Add the code in our app:

<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://mautic.realdomain.io/mtc.js','mt');

    mt('send', 'pageview', {email: 'ruben@gmail.com}, {onload: function() { alert("Tracking request is loaded"); },onerror:function(){alert('error');}});
</script>

2/ Run above
3/ Check the contact detail in Mautic: nothing added .

Config is like this:

Did u check anon contacts? Click the icon next to the little thunder icon on the contacts page.

Hi @joeyk ,
Yes, i checked, but no contact related to the tracking found…

Well, this JS above seems to be faulty. You didn’t close the quotation after the emal.

I would recommend to open the site which is tracked in chrome and open the developer console.

Then reload site.

Check for Javascript Problems in the console (Joey already spotted one problem in the js code snippet you posted)

Example from my console:

Then switch to the network tab and reload the site again. Look for the request to

/mtc/event

If you inspect the request in the network tab it should they something like:

{"success":1,"id":"34122","sid":"vdvndvndovndv","device_id":"cdjovhdovndovndovn","events":[false]}

(success = 1 is the important part here )

Screenshot:

The most common problem: mautic will NOT track your request if you are logged in to mautic at the same time. So make sure to clear the browser or better use another browser.

You mentioned that it is a webapplication. Please note that the javascript code just fires once every page you requested. If your webapplication is a single web application and loads via ajax other views, mautic will not recognize that with the default code.

Greetings
Sebastian

Ok, found the issue!
@sfahrenkrog1 it was indeed because i was logged in!
Everything works smoothly now.
Thanks @sfahrenkrog1 , @joeyk !

1 Like