Google Analytics is returning metrics values as follows:

However when trying to use this in a later step, it doesn’t allow me to use value by value:

Even when I try splitting that output, I get the same issue in a later step:



How can I solve this?
Google Analytics is returning metrics values as follows:
However when trying to use this in a later step, it doesn’t allow me to use value by value:
Even when I try splitting that output, I get the same issue in a later step:
How can I solve this?
Best answer by FlareBest answer by Flare
Fixed it thanks to ChatGPT. Here’s the solution for reference in case anyone else needs this.
Input:
Script:
// Function to split a comma-separated string into an array of numbers
function splitAndParse(str) {
return str.split(',').map(Number);
}
// Function to split a comma-separated string into an array of strings
function splitString(str) {
return str.split(',');
}
// Split the strings into arrays
const past7days = splitAndParse(input.past7days);
const previous7days = splitAndParse(input.previous7days);
const metricNames = splitString(input.metricnames);
output = {};
// Assign values from past7days array to the output object based on metricNames
for (let i = 0; i < past7days.length; i++) {
output[`${metricNames[i]}_past7days`] = past7days[i];
}
// Assign values from previous7days array to the output object based on metricNames
for (let i = 0; i < previous7days.length; i++) {
output[`${metricNames[i]}_previous7days`] = previous7days[i];
}
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.