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?

Bingo!

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 */
(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://marketing.torontoheadshot.com/mtc.js','mt');

if (qs !== '' && qs !== undefined){
    mt('send', 'pageview', {gclid:qs});
}else{
    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.

Hi @joeyk and @aglyons, I am trying to do the same thing but I need a little guidance. Hopefully you will be able to advice something to me.

I use GTM to inject tracking code as below:

<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://xmy-mautic-instancex.com/mtc.js','mt');  
  
    var glicd = {{URL String - glcid}};

    if(glicd !== '' && glicd !== 'empty') {
        mt('send', 'pageview', {gadscid: glicd});
    } else {
      mt('send', 'pageview'); 
   }
</script> 
  1. {{URL String - glcid}} returns “empty” when gclid don’t exists in query string and a string value when it does.
  2. gadscid is alias of my custom fields and it is publicly updatable. Also the field has type ‘text’.

So the problem is that this script works a little bit odd. Instead of enrich the anonymous visitor’s contact field it identifies them as recognized ones and put the ‘glicd’ value as a contact’s name.

In example below I used ‘123123’ as a parameter in query string: ?gclid=123123

It looks like when I pass 3rd parameter to mt() function it replaced whole object instead of extending it with ‘gadscid’ value.

Can you please sheed some little light on this?
Thanks in advance,
M.

I made some tests and it looks like maybe I am missing something. The reason of the issue is mechanism that allows to update “Public updatable” fields by query parameters. (docs). So it looks like passing URL’s parameter with the right name and value actually identified contact. From my point of view the contact should stay anonymous until email address is gathered or any form submitted.

However my script reads parameter from URL and it turned out that my custom field “Contact Google Ads Click ID” was set to “public updatable”. But when I switched it off then parameter that is passed inside mt('send', 'pageview', {gadscid: glicd}); is not stored in the field and contact stay anonymous.

I am started to think that everything works as suppose to but it is annoying to me that sending parameters inside mt() identified contact.

Can I ask anyone of you to make a test on your Mautic instance?

Thanks in regards, M.