Best answer

Zapier tweet/fb post random product URL each day?

  • 20 December 2019
  • 7 replies
  • 456 views

Userlevel 1

I'm trying to set up a simple zap.

I run an online store and I would like to post a "product of the day".

I'd like this to be random products from my website.

I'm wondering what's the best way to do this?


icon

Best answer by PaulKortman 20 December 2019, 19:07

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.

7 replies

Userlevel 7
Badge +10

@IcarusZaps Sounds fun,

There's a couple ways to solve this, but I would want to know what the ecommerce/CMS platform is that runs your site.

Because you could do this "manually" of having a list of product URLs in a Google Sheet that the Zap pulls a random row from, but you'd have to keep the sheet up to date if the Products or the product URLs change.

So based on the CMS I would see if you can have another zap that adds/deletes/modifies rows in that sheet when products are updated/added/removed from the site.

Once you get that then you could do one of the following methods for actually grabbing a "random" row from the sheet.

Option 1: round robin https://community.zapier.com/discussion/133/easy-edit-round-robins-using-a-google-sheet Basically start at the top and choose the next row each time, this ensures you're not repeating twice in a row. (I use the Modulo method mentioned by @tweiland in the comments on that thread.)

Option 2: random row selection: https://community.zapier.com/discussion/43/select-a-random-row-value-in-a-google-sheet use the RANDBETWEEN() To get a random row number between 2 and the last row. Then use a google sheets step to get the value of that row number.


Userlevel 1

Thank you. My initial instinct was to do the Google sheets. which might be the easiest. My second instinct was to do some sort of connection to my MYSQL database.


I think it might be easier to do the Google sheets version.

I'm using Opencart.

Thoughts?


Userlevel 7
Badge +10

OpenCart doesn't have a Zapier integration and it appears doesn't even have an API... so I found this https://opencart-api.com/ which you could install and then run a webhook to it asking for a list of products and write the results to the google sheet. - I would schedule that on a weekly basis (deleting the existing rows and then creating new rows from the results of the webhook call).

It can get pretty complex. But it's doable.


Userlevel 1

I can probably just go into my MSQL database and copy the SEO URLs. And then just paste them all to a sheet. That's probably easiest. And then I guess I would run whatever you mentioned above to tweet/posteach product daily?


Userlevel 7
Badge +10

@IcarusZaps Well if you wanted to automate the Mysql calls you could use this: https://zapier.com/apps/mysql/integrations


But yeah once you have the data in a Google Sheet just use one of the methods I mentioned/linked to above and run it with a schedule (daily) trigger.


Userlevel 1

@PaulKortman Thank you for this! I was able to set it up and test it overnight! works perfectly! :)


I want to try another zap using Google Sheets. Basically I have a price list and whenever a row is updated, I would like to send an email to my team. I tried to set it up using these instructions:

Get email notifications for new rows in a Google Sheets spreadsheet

But it's not really giving me the name of the row (the first column has the name of the product).

hmm? Any ideas.

Thanks so much for your help.


Userlevel 7
Badge +10

@IcarusZaps might be good to start a new thread on this one... but some gotchas with triggering off of a new row:

  • How is the row written? If by a human they might not enter it all before the trigger fires.
  • Are rows being deleted? If so it messes with a zap that triggers off of a new spreadsheet row (there's a way to overcome this)
  • Do each of the columns have a value in the first row? (aka column headers) If not, then that column will not be available to the Zap.

By the way, I'm not sure what you mean about the "name of the row" -- if you mean the value of the first column I would double check that the first column has a header (value in row 1).