Syncing a Google Sheet to a Mailjet List Without Re-Subscribing Anyone
A common setup: a customer list lives in a Google Sheet, and a nightly Apps Script job mirrors it into a Mailjet contact list so campaigns go to whoever is in the sheet. The simplest version of that job sends every row to Mailjet with the action addforce . It runs cleanly for weeks, and it re-subscribes anyone who clicked unsubscribe since the last run, because that is exactly what addforce is…
The process of syncing a Google Sheet to a Mailjet list without re-subscribing anyone involves understanding the four actions available for adding contacts to a list in Mailjet. The action "addforce" is problematic for this purpose as it not only adds contacts but also subscribes them, even if they had previously unsubscribed. This is because "addforce" does not account for prior unsubscribe status, which can be an issue when a scheduled job runs and pushes the entire sheet to Mailjet without recognizing prior unsubscribe status.
To resolve this, the recommended approach is to use "addnoforce" instead, which adds contacts without automatically subscribing them. Additionally, before any push operation, it's crucial to pull the unsubscribe data from Mailjet into the Google Sheet. This is done by querying the "listrecipient" resource with filters for unsubscribed members.
The response includes a "ContactID" for each unsubscribed member, which must be matched with the corresponding row in the Google Sheet using the list's contacts data. Since the API endpoints are paginated and return up to 1000 contacts per page, a loop must be implemented to fetch all unsubscribed contacts. This ensures the Google Sheet has the most current list of unsubscribed contacts before pushing any new data to Mailjet, effectively preventing re-subscription of people who have opted out.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.