Trigger a goal conversion when a row is added to a Google Sheet

Is there a way we could trigger a goal when a row is added to a Google Sheet?

We have a form that sends results to a Google Sheet. (It’s an embedded form hosted from a third party.) The goal we are tracking is the completion and submission of the form. So when the form sends results to to the sheet, we know it’s been successfully completed.

I’ve tried working through the challenge with a couple of AIs but had no success with the solutions they provide. They suggest adding a script to the sheet that triggers when the row is added, sending a signal to Matomo for the goal.

We have Matomo set up in our WordPress site via the plugin.

Thanks for any suggestions and help.

BTW: I have looked at creating a goal for the click of the submit button, but have had no luck creating that either.

I have not tried this yet, maybe this will help: Pulling Goal Data from API

From my understanding, you could also build on top of Matomo API + Google Sheets API, i.e. you’d have a Python script or PHP script that syncs those 2 APIs and based on your trigger from Google Sheets API it would mark that as a goal conversion through Matomo API.

As I said, it might or might not work, but pls let us know how you go with it. Thanks!

If the form is hosted on GForms… Then you’re out of luck because that’s another domain within an iframe, one that you cannot reach with your tracking code.

I’ve thought about it for a few minutes… Using the Matomo tracking API, you’re still required to give the visitor ID:

And since it’s stored in a 1st party cookie… That value cannot be passed on to the Google Form.

On the other hand… You could theoretically use the hashed email as uid/User ID… But you have the email ONLY after the user sends the form.

There’s no way you can stitch the data together, even if you’ll manage to track goals, you’ll not be able to assign goal to any of the dimensions, such as acquisition channels.

No luck, the only way out I see is actually using a 1st party form on your website.

Thanks for the ideas

If anybody is interested, this is the kind of thing I get from the AI. The script would be added to the AppScript for the Google Sheet that receives the data from the form (TypeForm). I’ve gone through several variations and had no success.

function sendToMatomo() {
var trackingUrl = “”; // Replace with your Matomo URL
var siteId = 1; // Replace with your Matomo site ID
var goalId = 12; // Replace with the appropriate goal ID

var pageUrl = “/path/to/dummy-url”; // Replace with the dummy or specific URL associated with the event

var payload = {
e_c: “Google Sheet”, // Event Category
e_a: “Row Added”, // Event Action
e_n: “New Row Added”, // Event Name (optional)
_id: siteId // Replace with your Matomo site ID

var options = {
method: “POST”,
payload: payload

UrlFetchApp.fetch(trackingUrl + “?idsite=” + siteId + “&rec=1&action_name=” + pageUrl + “&idgoal=” + goalId, options);

I’ve gone back to trying to identify the class of the submit button in form and MIGHT have that working.

Thanks for the responses

What about _id or uid?

As said, you wont be able to tie goals to channels, otherwise.