I’m trying to run a workflow that fetches the page view data from each page of a website and puts that data into a Cockpit collection so I can retrieve it as a HTML table.
For eaxmple, the pages: https:/ /mydomain . com?oc=12345 and https:/ /mydomain . com?oc=67890
I can run the workflow on each ‘oc’ value speratly and the workflow will put the data into the relevent Cockpit entry (the _id value is the same as the ‘oc’ value) - but I want to run the workflow on a schedule to update all of the pages/entries.
I have the following:
When it runs, the Google Analytics node fulls the data from ALL of the found pages with a result like:
If I try using multiple ids for the imput I get the same results as before - all the data for each page is returned into one item and the html table created by the ‘Build HTML5’ node contains all of it which is then sent to the first ID’s Cockpit entry.
It doesn’t loop through each ID and only use the GA4 data from that page.
How do I get it to loop through the inputs? I was under the impression that N8N did this automatically?
Hi @seank1968 ,
could you share your updated workflow so I can test it on my side?
n8n is supposed to loop all the IDs in INPUT and use all of those to filter the results.
Check this screen from my local version and let me know if this is what you’re trying to accomplish:
In my case, I have 4 IDS coming in the INPUT panel, these are used to filter the pages (I had to use .toString() otherwise it was failing to match numbers and strings), and the results in OUTPUT are grouped by page URL and Country.
Hi @giulioandreini yes, that is working for the the Google Analytics node it’s returning data for all the page IDs - but what I need to do is then process each page IDs results (create a HTML table and update a Cockpit entry) individually. The workflow I posted takes ALL of the Google data, creates a single table and updates the entry using the first page ID. How do I get it to look through each page seperatly?
Hi @seank1968 ,
so you need o create an html table for each page?
What information do you want to display on those tables?
Hopefully with those info I’ll be able to help
By the way a couple of things worth checking out:
in the latest version of n8n you find an HTML Node that allows you to create some HTML structures and runs for each items that receives in the INPUT
also the new Code Node allows you to choose if you want to run it for each items (“Run Once for Each Item” select at the top)
Let me know if one of these two things help and the structure of the table you want to obtain
I thought I had it working but it’s not quite there.
When the Google Analytics node runs it pulls in each county’s data into a seperate item - vthen the HTML node creates multiple tables with each item so there is only one line of data:
Can I get it to loop through the items and add them?
That HTML node is an excellent addition - I have a few workflows that generate an email at the end of the flow and it’s going to be much easier to create those with it!
Then if you want to have a single table with a row for each page you can do something like the example below.
In this case i first build the separate HTML rows in the HTML node, then merge them in the Code node, and inject them in an HTML table at once. This is just a way you can do it. You can get different configurations by combining the nodes HTML, Code, Items list.
In the image, IDs c7901783336463fd0c00004d and cb8bde7f63323081ac00010f are returning data (7 views and 69 views) as shown. The others are returning nothing as there are no views.
The HTML tables are being created - the first two for the above mentioned IDs:
@seank1968 that is normal as the Google Analytics Node in this case sets its own order and subset of items that will hardy correspond to the original one in Get Profile IDs.
Question: is it possible for you to retrieve the ID back from the URL of the page? With some string manipulation?
In that case, you could use a Set Node as in the example below and have the HTML and related ID in the same item.