[英]how to create tags in the lists of mailchimp subscriber using nodejs?
I had created the mail subscription using mailchimp.我使用 mailchimp 创建了邮件订阅。 The mail id is listed in the lists of mailchimp, but i want to pass the firstname,lastname and want to create a tag while doing the mailchimp subscription.
邮件 ID 列在 mailchimp 列表中,但我想传递名字、姓氏并希望在订阅 mailchimp 时创建一个标签。 but now i am listing only the mail under my list.. when i am trying to create the tag via postman, the tags are created, but i want to add through api code.
但现在我只列出我列表下的邮件.. 当我尝试通过 postman 创建标签时,标签已创建,但我想通过 api 代码添加。
var mailchimpInstance = '***',
listUniqueId = '*********',
mailchimpApiKey = '*****************';
app.post('/signup', function (req, res) {
request
.post('https://' + mailchimpInstance + '.api.mailchimp.com/3.0/lists/' + listUniqueId + '/members/')
.set('Content-Type', 'application/json;charset=utf-8')
.set('Authorization', 'Basic ' + new Buffer('any:' + mailchimpApiKey ).toString('base64'))
.send({
'email_address': req.body.email,
'status': 'subscribed',
'merge_fields': {
"FNAME": req.body.fname,
"LNAME": req.body.lname
}
})
.end(function(err, response) {
if (response.status < 300 || (response.status === 400 && response.body.title === "Member Exists")) {
res.send('Sign Up Success :)');
} else {
res.send('Sign Up Failed :(');
}
console.log(req.body.email);
});
});
This code is for sending the email to the lists..in this code the firstname and lastname is not listed in the lists of mailchimp..and i also need to create tags using this api此代码用于将 email 发送到列表中。在此代码中,名字和姓氏未列在 mailchimp 列表中。我还需要使用此 api 创建标签
There's a 'tags' body parameter which accepts an array and adds the tags to the mail id. 有一个“标签”主体参数,它接受一个数组并将标签添加到邮件ID。 Here's the documentation: https://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#%20
以下是文档: https : //developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#%20
If you want to create an email address AND add tags, you need to specify the tag as an array in the members field.如果要创建 email 地址并添加标签,则需要在成员字段中将标签指定为数组。
This drove me nuts as I noticed it had for a lot of other people reading through Stackoverflow.这让我发疯了,因为我注意到很多其他人通过 Stackoverflow 阅读它。
In your code, you would add the below when you are calling send.在您的代码中,您将在调用发送时添加以下内容。
In the below example, I had already created a tag:在下面的示例中,我已经创建了一个标签:
var data = {
status: "active",
members:[
{
tags: ["yourtagname"],
email_address: email,
status: "subscribed",
merge_fields: {
FNAME: firstName,
LNAME: lastName,
},
}
],
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.