2
votes

So I'm using node.js and i installed modulem ailchimp-api (https://npmjs.org/package/mailchimp-api) so i went to offical website to read how to send mailchimp email and i figured out standard procedure.

var MailChimpAPI = require('mailchimp').MailChimpAPI;

var apiKey = 'Your MailChimpAPI API Key';

try { 
    var api = new MailChimpAPI(apiKey, { version : '2.0' });
} catch (error) {
    console.log(error.message);
}

api.call('campaigns', 'list', { start: 0, limit: 25 }, function (error, data) {
    if (error)
        console.log(error.message);
    else
        console.log(JSON.stringify(data)); // Do something with your data!
});

api.call('campaigns', 'template-content', { cid: '/* CAMPAIGN ID */' }, function (error, data) {
    if (error)
        console.log(error.message);
    else
        console.log(JSON.stringify(data)); // Do something with your data!
});

I run on next problem ! How can I add my own text to the exsisting template in mailchimp ? I can choose campaign .. and write text ( on the web site of mailchimp ) but I wanted to send a confirmation link to the template but I dont figure out how can I do ...

maybee is some way to define the area where can i put text ? or should i copy entire html code and style from mailchimp and then put between the text the url link for confirmation ( not for subscription but for validation of user.

Thx for anwsers!

1
I got it .. 1. if you dont have list in mailchimp create it ... 2. then go to settings in list and pick "List fields and |MERGE| tags 3. then add new field (field label, field type, required, visible, put this tag in your content) (I puted under tag ACTIVATED) 4. next ste is to add this tag to the template ... you find it under text editor tab "Merge Tags" 4. in node.js call function mc.lists.subscribe(data, function(data)) ... ( data is :Maco

1 Answers

1
votes

I got it.

  1. If you don't have list in mailchimp, create it.

  2. Go to settings in list and pick "List fields" and "|MERGE|" tags.

  3. Add new field (field label, field type, required, visible, put this tag in your content) (I put under tag "ACTIVATED")

  4. Add this tag to the template. You find it under text editor tab "Merge Tags".

  5. In node.js, call function mc.lists.subscribe(data, function(data)).