Mautic Community Forums

Anonymous visitor > add items to tracking data

Your software
My Mautic version is: 4.0.2
My PHP version is: 7.4

So my ongoing quest to get gclid ID into contact records. I’ve managed to pull the gclid from the URL and store it in a cookie value.

I was going to inject that into a hidden form field but I felt that if I could push it into the anonymous visitor record the second they hit the site then I would also get a clear view of just how many AD clicks I was getting.

I’d still need the form to ID the contact prior to them making a booking.

My question now is anonymous visitors are tracked by some method that I can’t find. Is there a way for me to edit the data that is sent when they hit a page?


Here’s an anonymous visitor coming in from a GADs click. It has the gclid in the URL. I really would like to grab that on this anonymous visit and push that into the contact record field. @joeyk are you able to shed some light on this?

Hi, do you mean you want to save this value and save it in a custom field? You can only do it with some custom code.

You can check for the gclid string in this field by ‘contains’ gclid expression but that will give you a yes or know outcome only. Maybe that is enough.

I have the gclid stored in a cookie so that part is done. It’s getting it into the anonymous record that is the problem. Would the regular mt() track push that in or does that need an email address to match up?

When you send the MT function then the current contact will get the value - anon or not.

Hey Joeyk,

So in my testing, I modified the tracking block to include the gclid QS var.

/** Send Mautic track */

if (qs !== '' && qs !== undefined){
    mt('send', 'pageview', {gclid:qs});
    mt('send', 'pageview');

I have tested the script at various breakpoints and I can see the QS value being added to the mt() call. But it never hits the contact record ever. Whether the contact is known or unknown, the gclid contact field never gets updated.

I really feel like I’ve found a new bug.

I’m open to having a Skype chat and screen share to go over what I have found if you are.

1 Like

I am very interested in hearing the outcome of this discussion

Hi! Is the format matching the contact field and how you are trying to pass the data? Is this a string? Is the field publicly updateable?
Is the contact field alias correct? If you are writing

 mt('send', 'pageview',  {gclid:’abc123’});

Is it passed?

OK, I figured out the issue.

Nowhere in the docs under contact tracking does it mention that you can’t refer to the field name, it has to be the field alias. I think that should be underscored in the documentation.

Using the alias name worked correctly.

mt('send', 'pageview', {gads_gclid:’abc123’});

Thanks for the idea.