Best answer

How can I use different metrics of Google Analytics 4 output? Splitting text doesn't work.

  • 16 August 2023
  • 11 replies

Userlevel 1

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 Flare 18 August 2023, 17:42

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

11 replies

Userlevel 6
Badge +6

Hi @Flare ,


What is the expected output do you want? Do you want to sum all the numbers and than send to Slack?

Userlevel 1

Hey @jayeshkumarbhatia! I want the numbers separately (value by value), not in comma separated blob.

Userlevel 6
Badge +6

You can use Looping by Zapier, that should solve your problem. You can add Looping by Zapier action just above Slack Send Message action.

Userlevel 1

No, I don’t want to send a bunch of Slack messages. I want to use all numbers in one Slack message.

Userlevel 6
Badge +6

Can you show me/share screenshot on the expected output that you want? 

Userlevel 1


I have two steps that get Google Analytics data (from past 7 days & from 7 days previous to those). I want those all in one Slack message. 

Userlevel 1

Anyone? :)

Userlevel 6
Badge +6

Hi @Flare , You can write a Javascript code to extract the Google Analytics value from the array and create Slack message they way you want

Userlevel 1

Wouldn’t it be easier if the text formatter actually did what it’s supposed to do and deliver an output that is usable?

Userlevel 1

Fixed it thanks to ChatGPT. Here’s the solution for reference in case anyone else needs this.



// 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];
Userlevel 7
Badge +11

That’s awesome news, @Flare! 🎉 Thank you so much for sharing details of the solution you found - I’m sure it'll be invaluable to other folks in the Community here! 🤗