Sending analytics to my site from an unknown site

I’m about to sell some JavaScript code using an online market place and wondering if there is a way to use Matomo to send data from the customer’s site (where they have added the JavaScript they have purchased from me). I’m thinking there must be a restful way such as sending a query string containing the customer’s URL and other analytics back to my Matomo site. I would include these restful calls in the JavaScript in an obsfucated/minified way so they hopefully don’t get removed by the customer, but I appreciate that another JavaScript developer would be able to remove it. Any ideas to point me in the right direction will be greatly appreciated. Note that I won’t be collecting personally identifiable data such as the customer’s IP address, so would not require consent. The reason I would like to collect this data is to see how much my JavaScript is being used and from which sites, and ideally be able to identify if there is anyone using the JavaScript that didn’t purchase it from the online market place.

I think I found what I was looking for here: https://developer.matomo.org/guides/tracking-javascript-guide
I just needed to spend a bit more time looking.

Hi @MrZombie
Be careful, some browsers (and also site configuration especially CSP headers) can prevent the sending of information to your Matomo server… :frowning:

Also, some developers could do retro engineering on your code, and then copy then remove the tracking part…

Thanks Phillippe,
I think it’s ok if it fails to send the data back to the matomo site if the user’s browser etc prevent it from working, as long as that doesn’t cause an error and prevent other JavaScript from working. I’ll make sure the matomo pushes are the last calls made. I’m expecting most customers to have standard browser setups.
I’m also not too worried about it being reverse engineered. I’m using https://obfuscator.io/ to obsfucate the JavaScript which makes it pretty hard to understand. It seems like it would be easier to figure out what I did from scratch than decipher the obsfucated JavaScript.
On another note, I’m having trouble getting customDimensions to work. I have set them up in my matomo dashboard and using this JavaScript push:
_paq.push([‘setCustomDimension’, customDimensionId = 1, customDimensionValue = lastError]);
In my JavaScript the lastError variable equals 0 by default, but in my matomo dashboard I’m getting the message “There is no data for this report.” I must be missing something. I couldn’t figure out if my lastError variable was an acceptable value to push. Does it need to be in a different format, such as an object? Or am I missing something else? I read that it could take a while for this data to update in the matomo site (after archiving?). I have waited a day with no change.

I just noticed that my customDimensions have started updating in the dashboard. I must have set it all up correctly and took a bit longer than a day to propgate.