Linking data to contacts
Plunk can be considered as a lightweight CRM system. It allows you to link data to contacts. This is useful for storing information about your users and later using it in marketing automations and campaigns.
Linking data on event triggers
The best way to link data to contacts is to do it on event triggers. For example, when a user creates a new project, you can link the name of the project to the user. To do this, you add the data parameter to the event trigger. The data parameter is an object that contains key-value pairs of the data you want to store.
It is important to note that the key of the data parameter is case-sensitive and unique. If you try to add a key that already exists in a contact, the previous data will be overwritten automatically.
await fetch('https://api.useplunk.com/v1', {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer API_KEY", // Put your API key here
},
body: JSON.stringify({
"event": "new-project",
"email": "hello@useplunk.com",
"data": {
"project": "Plunk"
}
}),
});
import requests
requests.post(
"https://api.useplunk.com/v1/track",
headers={
"Content-Type": "application/json",
"Authorization": "Bearer API_KEY" # Put your API key here
},
json={
"event": "new-project",
"email": "hello@useplunk.com",
"data": {
"project": "Plunk"
}
},
)
curl --location --request POST 'https://api.useplunk.com/v1' \
--header 'Authorization: Bearer API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{"email": "hello@useplunk.com", "event": "new-project", "data": {"project": "Plunk"}}'
<?php
$client = new Client();
$request = new Request('POST', 'https://api.useplunk.com/v1', ['Authorization' => 'Bearer API_KEY', 'Content-Type' => 'application/json'], '{
"event": "new-project",
"email": "hello@useplunk.com",
"data": {
"project": "Plunk"
}
}');
$res = $client->sendAsync($request)->wait();
require "uri"
require "json"
require "net/http"
url = URI("https://api.useplunk.com/v1/track")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer API_KEY" # Put your API key here
request["Content-Type"] = "application/json"
request.body = JSON.dump({
"event": "new-project",
"email": "hello@useplunk.com",
"data": {
"project": "Plunk"
}
})
response = https.request(request)
Consuming data in templates
You can use the data you linked to contacts in your templates. For example, the project name you linked to the user in the previous example can be used in a template like this:
Hey there!
You created a new project called {{project}}.
Consuming data in transactional emails
Linked data can also be used in the subject and body of transactional emails.
await fetch('https://api.useplunk.com/v1/send', {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer SECRET_KEY", // Put your API key here
},
body: JSON.stringify({
"to": "hello@useplunk.com",
"subject": "Thanks for signing up!",
"body": "<h1>Your new project is called {{project}}</h1>",
}),
});
import requests
requests.post(
"https://api.useplunk.com/v1/send",
headers={
"Content-Type": "application/json",
"Authorization": "Bearer SECRET_KEY" # Put your API key here
},
json={
"to": "hello@useplunk.com",
"subject": "Thanks for signing up!",
"body": "<h1>Your new project is called {{project}}</h1>",
},
)
curl --location --request POST 'https://api.useplunk.com/v1/send' \\
--header 'Authorization: Bearer SECRET_KEY' \\
--header 'Content-Type: application/json' \\
--data-raw '{"to": "hello@useplunk.com", "subject": "Thanks for signing up!", "body": "<h1>Your new project is called {{project}}</h1>"}'
<?php
$client = new Client();
$request = new Request('POST', 'https://api.useplunk.com/v1/send', ['Authorization' => 'Bearer SECRET_KEY', 'Content-Type' => 'application/json'], '{
"to": "hello@useplunk.com",
"subject": "Thanks for signing up!",
"body": "<h1>Your new project is called {{project}}</h1>",
}');
$res = $client->sendAsync($request)->wait();
require "uri"
require "json"
require "net/http"
url = URI("https://api.useplunk.com/v1/send")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer SECRET_KEY" # Put your API key here
request["Content-Type"] = "application/json"
request.body = JSON.dump({
"to": "hello@useplunk.com",
"subject": "Thanks for signing up!",
"body": "<h1>Your new project is called {{project}}</h1>",
})
response = https.request(request)