Sort CMS by Popular posts - The No-Code Solution

Hey,

So I’ve been desperately trying to figure out a way to sort posts using the amount of view, but of course, Webflow doesn’t support this. I’ve seen people suggesting using Zapier but you can only get new Google Analytics Goal as triggers in Zapier, so here’s what I’ve attempted.

  1. Get Google Analytics Blog views into Google Sheets that updates once a day.
  2. Use Sheet & Zapier to update a views field in the Blog Article CMS.

So #1 was easy. Used the Google Sheets Google Analytics addon to create a report that filtered for Blog Posts and runs once a day:
configuration
Then added a sheet that would be used by on a daily bases to get the views and slug for Zapier using an Array and regexreplace:


The idea here was that I could update the CMS posts on a daily basis with the new Views. I regexed the slug as I can’t use Title (we have posts with the same name for different regions, so would need their slug and not title to find the post to update).

This is pretty much how far I got. I’ve got two issues, one, how do I update just the views field for the post? Two, can I identify the post using it’s slug and not it’s Title?

Hoping someone has the experience or brainpower to figure out his last step.

Project Read Only

For issue one, use the Patch item request to update only the field you want to change.
For issue two identify the post by its unique id which resolves the ‘same name for different regions’ issue.

1 Like

How would I get the unique ID via Google Analytics can I capture it in Tag Manager or something?

You will see this in the CMS API response.

@Gail_Ranger Sorry, not sure what you mean here, what API response? I’m getting the views from the GA and the rest is Zapier so no IDs in GA?

Sorry for the confusion I’m referring to the Webflow CMS API. I assume you would be able to read the ID from Zapier but I haven’t tried it.

Hey everyone, did anyone find a solution to this? I’m in the same boat – need to sort posts by popularity, preferably page views.

1 Like

Still need to find time and figure out a way to update the field in the right post via zapier. Might try something like Airtables if that doesn’t work, but by then it.might just be too much of a pain in the ass.

@J8kes Can solve this if you need… just let me know.

@J8kes the tricky part of this is that Webflow’s API doesn’t have a search endpoint so matching up the collection item to a slug is tough. I think using the webhook method on collection item creation to send the id out and return it to a field on the collection itemmight be your best bet. As @Jeandcc posted in this thread you could do that with Zapier or any sort of web application framework (i.e. Flask).

If Webflow had a search endpoint on the API this would be much simpler, but I’m not sure of another way to do it. I suppose you could call the Get All Items in Collection endpoint and then wade through the response to search the slug and find the id, but once you hit over 100 collection items you’ll have to deal with pagination.

If anyone else has a simpler method I’m all ears.

FYI, get all items for a collection can be found here: Webflow API and Documentation | Webflow in the documentation.

The response isn’t that complex actually:

{
  "items": [
    {
      "_archived": false,
      "_draft": false,
      "color": "#4CAF50",
      "featured": false,
      "name": "5 Principles Of Effective Web Design",
      "post-body": "<h2>Earum laboriosam ab velit.</h2><p>Et aliquam fuga corporis sit assumenda culpa minima nostrum. Rerum corrupti cum quod laborum a. Non voluptatum ipsam ut et nostrum. Omnis deleniti hic est velit nemo et.</p><h3>Ut recusandae eveniet cum fugit.</h3><blockquote>Sed consectetur nulla dolorem explicabo temporibus aut. Assumenda ea reprehenderit voluptatem quis odit. Sequi sunt vel et dolorem qui dolorum ex. Omnis qui debitis eaque.</blockquote><p>Cumque et reiciendis sit ipsa. Odit sint dolor aliquam. Autem est odio voluptates deleniti. Voluptas quod dolorem minus natus necessitatibus. Autem ea iusto sunt repudiandae. Voluptatem ut et distinctio vero aliquid.</p><p>Aut ut eius. Sit quia labore nesciunt enim nemo eius pariatur odio inventore. Dolorem sapiente maxime laudantium vero praesentium. Fuga neque ipsam doloremque officia accusamus beatae ut occaecati aut. Aperiam perferendis et.</p><h2>Incidunt dolores assumenda tenetur ut recusandae officiis inventore modi quia.</h2><p>Aut necessitatibus qui nesciunt dolores dolores delectus nostrum occaecati odit. Quia optio et enim. Illo ipsa omnis quia quo ducimus voluptas placeat. Voluptatum consequatur id rem aut dolorem nesciunt. Est occaecati vero. Velit magni amet dignissimos.</p><h3>Voluptatem magni dolor quis hic quia iusto aut rerum quasi.</h3><blockquote>Repudiandae laborum necessitatibus dolorem accusamus sit et amet doloremque. Rerum illum rerum officia dolorum perferendis soluta aut incidunt autem. Rerum ut non corrupti maiores architecto vitae rerum quaerat ab. Est sint dolores quia repudiandae et eveniet. Et tenetur similique non ad. Quibusdam qui dolores dignissimos vitae reiciendis nulla aut necessitatibus.</blockquote><p>Voluptatem quia enim quos laudantium est. Dolorem earum est. Ut autem nemo accusamus quibusdam et dignissimos ut. Similique quia cumque. Aut pariatur repellendus voluptates error fugit illo. Neque pariatur impedit accusantium sed aut ea fuga magni ex.</p><p>Iusto accusamus quia nisi rerum reiciendis minus quam debitis. Sit illo eos qui. Nisi et autem sequi.</p>",
      "post-summary": "Quo eligendi nihil quia voluptas qui.\nNon distinctio voluptatu",
      "thumbnail-image": {
        "fileId": "580e63ff8c9a982ac9b8b74d",
        "url": "https://d1otoma47x30pg.cloudfront.net/580e63fc8c9a982ac9b8b744/580e63ff8c9a982ac9b8b74d_1477338111010-image3.jpg"
      },
      "main-image": {
        "fileId": "580e63fe8c9a982ac9b8b749",
        "url": "https://d1otoma47x30pg.cloudfront.net/580e63fc8c9a982ac9b8b744/580e63fe8c9a982ac9b8b749_1477338110257-image20.jpg"
      },
      "slug": "5-principles-of-effective-web-design",
      "updated-on": "2016-10-24T19:42:46.957Z",
      "updated-by": "Person_5660c5338e9d3b0bee3b86aa",
      "created-on": "2016-10-24T19:41:52.325Z",
      "created-by": "Person_5660c5338e9d3b0bee3b86aa",
      "published-on": "2016-10-24T19:43:15.745Z",
      "published-by": "Person_5660c5338e9d3b0bee3b86aa",
      "author": "580e640c8c9a982ac9b8b77a",
      "_cid": "580e63fc8c9a982ac9b8b745",
      "_id": "580e64008c9a982ac9b8b754"
    }
  ],
  "count": 1,
  "limit": 1,
  "offset": 0,
  "total": 5
}

You could probably write something like this to search for the slug after retrieving:

for item in items:
  if item[slug] == your-slug:
   id = item[_id]
return id

This is just a basic example of how this might be done in Python, obviously this is not tested or even close to final code. It’s just the basic logic of iterating through the response to find a slug and returning the id of that slug.

Then you would just have to put that id in your spreadsheet or database next to the slug.

Hi all, so spent some time last week to figure this one out and I have a no-code solution using Zapier, Google Analytics, Google Sheets and the Mixed Analytics API Connector that now updates my blog pageviews in the Webflow CMS so I can sort a collection list by pageviews. Seems to be working just fine. Not the easiest thing to do, but it’s updating a few times a day and it’s working. Will look into getting someone to write some code one day that I can host somewhere, but this works. Here’s the post on how we did it:

Creating a no-code Webflow Popular Post Section using Zapier, Google Analytics, Google Sheets and the Mixed Analytics API Connector

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.