{
  "elementsLearnedData": [],
  "elementsTestData": [],
  "flow": {
    "id": "57D805FB-1AE0-4968-B3E9-6A3CBD44B8CE",
    "name": "Fathom Analytics: daily conversions by campaign"
  },
  "flowVersion": {
    "clientMetadata": {
      "viewport": {
        "x": -70,
        "y": 0,
        "zoom": 1
      },
      "autoSave": false,
      "descriptions": {
        "flow": "Each morning, pulls yesterday's purchase conversions and value from Fathom Analytics by UTM campaign, converts the value from cents, and adds one row per campaign to a Google Sheet.",
        "initialData": "",
        "initialDataFields": {}
      }
    },
    "description": "Each morning, pulls yesterday's purchase conversions and value from Fathom Analytics by UTM campaign, converts the value from cents, and adds one row per campaign to a Google Sheet.",
    "elements": [
      {
        "clientMetadata": {
          "notes": "Builds a custom report for one event of a site: conversions, unique conversions or value, as totals or grouped by date and by fields such as page, referrer or UTM campaign, filtered and sorted. Returns one object per row, with every number as text and value in cents.",
          "elementId": "EXTENSION:::SHARED:::default:::fathom-analytics:::getEventReport",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Yesterday's purchases by campaign Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::fathom-analytics:::getEventReport",
          "legacyElementId": null,
          "methodName": "getEventReport",
          "position": {
            "x": 420,
            "y": 40
          }
        },
        "flowElementId": "5F49F80D-67F5-4D6A-ADDC-0934A89264C8",
        "groupId": null,
        "id": "E2AFF87E-A720-4322-BB19-D5AA2EA4E54E",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "siteId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Site ID",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Site ID"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "eventName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Purchase event",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Purchase event"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "aggregates",
              "type": "SIMPLE_LIST",
              "value": [
                {
                  "expression": [
                    {
                      "id": "TEXT",
                      "label": null,
                      "type": "INPUT",
                      "value": "conversions"
                    }
                  ],
                  "mode": "BASIC",
                  "parseJsonString": false,
                  "resultType": null
                },
                {
                  "expression": [
                    {
                      "id": "TEXT",
                      "label": null,
                      "type": "INPUT",
                      "value": "unique_conversions"
                    }
                  ],
                  "mode": "BASIC",
                  "parseJsonString": false,
                  "resultType": null
                },
                {
                  "expression": [
                    {
                      "id": "TEXT",
                      "label": null,
                      "type": "INPUT",
                      "value": "value"
                    }
                  ],
                  "mode": "BASIC",
                  "parseJsonString": false,
                  "resultType": null
                }
              ]
            },
            {
              "name": "dateFrom",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Yesterday",
                    "subPathSegments": [
                      {
                        "key": "from",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "16541623-40E8-48BB-844D-C156A7CCADFC"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dateTo",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Yesterday",
                    "subPathSegments": [
                      {
                        "key": "to",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "16541623-40E8-48BB-844D-C156A7CCADFC"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dateGrouping",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "fieldGrouping",
              "type": "SIMPLE_LIST",
              "value": [
                {
                  "expression": [
                    {
                      "id": "TEXT",
                      "label": null,
                      "type": "INPUT",
                      "value": "utm_campaign"
                    }
                  ],
                  "mode": "BASIC",
                  "parseJsonString": false,
                  "resultType": null
                }
              ]
            },
            {
              "name": "filters",
              "type": "COMPLEX_LIST",
              "value": []
            },
            {
              "name": "sortBy",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "value"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sortDirection",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "desc"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "limit",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 1000
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Yesterday's purchases by campaign', Error: The placeholder \"Site ID\" has no value",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "getEventReport",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Purchases",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "fathom-analytics",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Yesterday's purchases by campaign",
        "nextElementIds": [
          "8D47778D-4A1F-4DAD-B796-F55A6991E036"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Turn cents into amounts Result"
          },
          "position": {
            "x": 827,
            "y": 49
          }
        },
        "flowElementId": "B1BEE8F2-8659-43FD-8F1C-24399720C51A",
        "groupId": null,
        "id": "8D47778D-4A1F-4DAD-B796-F55A6991E036",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "report",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Purchases",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "E2AFF87E-A720-4322-BB19-D5AA2EA4E54E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "date",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Yesterday",
                    "subPathSegments": [
                      {
                        "key": "date",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "16541623-40E8-48BB-844D-C156A7CCADFC"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const num = v => { const n = Number(v); return Number.isFinite(n) ? n : 0; };\nconst rows = (Array.isArray(report) ? report : [])\n  .filter(r => num(r.conversions) > 0)\n  .map(r => ({\n    'Date': date,\n    'Campaign': r.utm_campaign || 'No campaign',\n    'Conversions': num(r.conversions),\n    'Unique conversions': num(r.unique_conversions),\n    'Value': Math.round(num(r.value)) / 100,\n  }));\nreturn { rows, count: rows.length };"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Rows",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Turn cents into amounts",
        "nextElementIds": [
          "242E8E45-5331-4EE3-B43F-4603B77CFB17"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 1154,
            "y": 49
          }
        },
        "flowElementId": "EC545600-B772-4C17-8322-52AC4B085290",
        "groupId": null,
        "id": "242E8E45-5331-4EE3-B43F-4603B77CFB17",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "28c4f70e-60d7-4be0-9a76-4141ee74b2d3",
                "nestedOperation": null,
                "operation": "arrayIsNotEmpty",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Rows",
                      "subPathSegments": [
                        {
                          "key": "rows",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "8D47778D-4A1F-4DAD-B796-F55A6991E036"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "ARRAY",
                "values": []
              }
            ],
            "grouping": [
              "28c4f70e-60d7-4be0-9a76-4141ee74b2d3"
            ]
          },
          "elseComponent": null,
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Any purchases",
          "storeResult": false,
          "thenComponent": {
            "componentId": "AF274765-CFC1-49C7-B399-D875F3D8FCB1",
            "componentType": "ELEMENT"
          }
        },
        "name": "Any purchases yesterday?",
        "nextElementIds": [
          "AF274765-CFC1-49C7-B399-D875F3D8FCB1"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": true,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Set yesterday's dates Result"
          },
          "position": {
            "x": 110,
            "y": 49
          }
        },
        "flowElementId": "5236C462-4701-4C66-A382-D490F2F5636E",
        "groupId": null,
        "id": "16541623-40E8-48BB-844D-C156A7CCADFC",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const d = new Date();\nconst y = new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate()) - 86400000).toISOString().slice(0, 10);\nreturn { date: y, from: `${y} 00:00:00`, to: `${y} 23:59:59` };"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Yesterday",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Set yesterday's dates",
        "nextElementIds": [
          "E2AFF87E-A720-4322-BB19-D5AA2EA4E54E"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Adds multiple data rows to Google Sheets in bulk for AI agents to efficiently store large datasets, batch process results, or import data from external sources. Essential for high-volume data operations and bulk data migration workflows.",
          "elementId": "EXTENSION:::SHARED:::default:::google-sheets:::addRows",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Add a row per campaign Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::google-sheets:::addRows",
          "legacyElementId": "JS###v1###GoogleSheets###addRows",
          "methodName": "addRows",
          "position": {
            "x": 1161,
            "y": 210
          }
        },
        "flowElementId": "F8265167-0E1A-41EE-987B-EE8C4E5AD73E",
        "groupId": null,
        "id": "AF274765-CFC1-49C7-B399-D875F3D8FCB1",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "documentId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Conversions sheet",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Conversions sheet"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sheetId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 0
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "rows",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Rows",
                    "subPathSegments": [
                      {
                        "key": "rows",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "8D47778D-4A1F-4DAD-B796-F55A6991E036"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Add a row per campaign', Error: The placeholder \"Conversions sheet\" has no value",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "addRows",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Added rows",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "google-sheets",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Add a row per campaign",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      }
    ],
    "firstElementId": "16541623-40E8-48BB-844D-C156A7CCADFC",
    "groups": [],
    "id": "448486EB-8CA0-4B84-96A0-8C7D4225855F",
    "metaInfo": {
      "clientValidationState": {
        "errorMessage": "Please fix problems before start. Blocks with issues have red badge in the top-right corner of a block, hover it to see what needs to be done.",
        "valid": false
      },
      "errorMessage": "Please fix problems before start. Blocks with issues have red badge in the top-right corner of a block, hover it to see what needs to be done.",
      "executionStaticData": [
        {
          "description": "The Fathom Analytics site to report on: its site ID, the same string as in its tracking code (for example CDBUGS).",
          "error": null,
          "name": "Site ID",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "The name of your purchase event in Fathom Analytics, exactly as it is tracked.",
          "error": null,
          "name": "Purchase event",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "URL or ID of the Google Sheet that gets one row per campaign per day. Its first tab needs the headers Date, Campaign, Conversions, Unique conversions and Value.",
          "error": null,
          "name": "Conversions sheet",
          "type": "STRING",
          "value": ""
        }
      ],
      "initialData": null,
      "initialDataDefaultValues": {},
      "ownerFlowVersionId": null,
      "schedule": null,
      "sharedMemory": {
        "anchor": {
          "missingAnchorPolicy": null,
          "path": null,
          "type": "FLOW_MEMORY"
        },
        "expirationInSec": null
      },
      "wasLive": false
    }
  },
  "slaCalendars": [],
  "slaGoals": [],
  "subFlows": [],
  "exportDate": "2026-12-02T01:42:19.469Z"
}
