Hi people, Im developing an integration from Tracking Js Script.
Theres any way to send a “Post” without ‘pageview’ argument in 'mt ’ payload?
I want to send custom field values, but donw want to send a new page view.
I did it work from gif tracking, but, the js has some more information to send.
Also interested plz keep the answers coming.
That would be truly nice.
Do you want to send it after the initial send event on pageload?
Like: If someone scrolls to 20% of page then send again?
Or would it be ok to send it directly at the beginning?
What happens when you call with something other than pageview param and data? Check if it still records page hit if you set ‘mytestdatatransfer’ instead of ‘pageview’,
In my experience, if you send any event other than “pageview” the event never gets picked up on the Mautic side, so any field updates are missed as well.
Yes, you can send the same payload, but, when you don´t send pageview string, Mautic dont accep the request. theres no error, just nothing happends…
I want to send data about the product os the purchase, but dont need to register the page view again, the “original” tracking was doing this.
I just want to update the fields.
We have this exact need as well
I mean the easiest way is probably to create another public api endpoint (custom plugin), the most proper way would probably be to extend mautic in a way that it accepts something other than pageview param.
I came up with this simple script today. Of course you need to fit it to your needs and use some other things like fetching the id of the current visitor to use it within the script but maybe it helps:
//create Mautic URL for API Call
var mauticUrl = "https://yourmauticurl.com";
var apiEndpoint = "/api/contacts/ID/edit"; //change ID to the contactID you want to change
var urlForXhr = mauticUrl + apiEndpoint
// user credentials for Basic Auth
var user = "mauticuser";
var password = "safepassword";
// Encode the user and password to base64
var encodedAuthString = btoa(user + ":" + password);
console.log(encodedAuthString);
// make the httpRequest
var xhr = new XMLHttpRequest();
xhr.open("PUT", url);
xhr.setRequestHeader("Authorization", "Basic " + encodedAuthString);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
console.log(xhr.status);
console.log(xhr.responseText);
}};
// input the data you want to insert
var data = `{
"firstname": "Mister",
"lastname": "Beast"
}`;
xhr.send(data);
Maybe it is a start? Would be great to hack around a little bit more
which platform do you use for the cart/checkout?
Do you have the data available?
You could simply send the data via the API to Mautic.
That is what most Plugins do anyway.
Is this javascript? If yes, then your psw will be exposed in my opinion.
Yes that’s JS. And yes. If you use basic auth it would be exposed if you put the script directly to the page. Better to store the script on the server and simply call it via an event. If you use https it should be safe. Of course someone with server-access can see the password in the script file.
The better solution would be to use oauth2 for that. But that takes a little bit more work…
Alex
Maybe you collet any object and send this payload to a php function for this file execute the API request, did will hide your credentials.
But, for my question, this is “haevy” request (call api, autentication, payload, update…), think this for a site with 2k simultaneos visit…
From jscript is light, as a void connection, recive the request without callback. I just want to do it more light, more fast and more efficient.
Hey leonardoborlot
I’m wondering:
Which informations are you missing in the gif tracking?
You could load the mtracking.gif also via javascript and append every parameter needed. So there should be nothing missing .
But using mtracking.gif will produce pagehit Entries in the lead detail page.
Could you give an example?
@leonardoborlot if you have very high traffic, it is likely that your Mautic server is not responding for every other call you send. Therefore you could build a queue with a database to truly get every call and make sure you don’t miss something because mautic is currently busy with other cronjobs, locked database und so on.
I implemented a similar solution, but I could not avoid the page view event, I just work with it, check the video and see if this is similar to what you need:
I found a hack to send events without any informations in the lead profile (with one little exception: you need to set a tag but it could be always the same)
You send a request to
/dwc/<RANDOMSTRING>?<PUBLICFIELDALIAS>=<VALUE>&tags=<ANYTAGYOULIKE>
Replace <RANDOMSTRING> with any string you like, and replace <PUBLICFIELDALIAS> with the alias you like to update and <VALUE> with the value.
<ANYTAGYOULIKE> could be any tag. It is just to force lead update.
Example with my mautic development instance:
https://m.dev.testserver.online/dwc/randomstring?uuid=SEBASTIAN&tags=save
uuid is a public field in my instance
and tags could be any value you like (this is just to force lead update for the field)
good ideia. good vídeo.
but, think so, you don need to create a new line in database to registra this page view, just to send a new tag change or add points.
This is whats we are looking for.