A segment is a group of people. You can manually control which people you add or remove from the group. You can also use entry and exit rules to automatically add people who comply with the entry rules or remove people based on the exit rules.
You can add or remove people from a segment manually or automatically.
To add or remove people from a segment automatically using our API, follow the examples below. If your language does not appear in the examples, don't worry, you just need to send an HTTP POST request as shown in this section.
To add and remove people from a segment using PHP (using Composer):
$ composer require convertloop/convertloop-php
ConvertLoop\ConvertLoop
class passing your credentials:
$convertloop = new \ConvertLoop\ConvertLoop("your_app_id", "your_api_key", "v1");
add_to_segments
key:
$convertloop->people()->createOrUpdate(array(
"email" => "[email protected]",
"add_to_segments" => array("Segment 1", "Segment 2")
));
You can also remove people from segments with the remove_from_segments
key:
$convertloop->people()->createOrUpdate(array(
"email" => "[email protected]",
"remove_from_segments" => array("Segment 1")
));
Learn more about the attributes of the create or update function
If you implemented a previous version of ConvertLoop's API using Tags, don't worry: all your Tags have already been automatically converted into Segments, and there is no action required in your code implementation to make them work.
To add and remove people from a segment using Ruby on Rails:
gem 'convertloop', '0.1.2'
bundle install
from the command line.config/initializers/convertloop.rb
and paste the following code:
ConvertLoop.configure(
app_id: 'your_app_id',
api_key: 'your_api_key'
)
add_to_segments
key:
ConvertLoop.people.create_or_update(
email: "[email protected]",
add_to_segments: ["Segment 1", "Segment 2"]
)
You can also remove people from segments with the remove_from_segments
key:
ConvertLoop.people.create_or_update(
email: "[email protected]",
remove_from_segments: ["Segment 1"]
)
Learn more about the attributes of the create or update function
If you implemented a previous version of ConvertLoop's API using Tags, don't worry: all your Tags have already been automatically converted into Segments, and there is no action required in your code implementation to make them work.
To add or remove people from a segment using Ruby (without bundler):
$ gem install convertloop
require 'convertloop'
ConvertLoop.configure(
app_id: 'your_app_id',
api_key: 'your_api_key'
)
add_to_segments
key:
ConvertLoop.people.create_or_update(
email: "[email protected]",
add_to_segments: ["Segment 1", "Segment 2"]
)
You can also remove people from segments with the remove_from_segments
key:
ConvertLoop.people.create_or_update(
email: "[email protected]",
remove_from_segments: ["Segment 1"]
)
Learn more about the attributes of the create or update function
If you implemented a previous version of ConvertLoop's API using Tags, don't worry: all your Tags have already been automatically converted into Segments, and there is no action required in your code implementation to make them work.
To add or remove people from a segment using Node.js:
$ npm install convertloop
const Convertloop = require('convertloop')
const convertloop = new Convertloop({
app_id: 'your_app_id',
api_key: 'your_api_key'
})
add_to_segments
key:
convertloop.people.create_or_update({
email: "[email protected]",
add_to_segments: ["Segment 1", "Segment 2"]
})
You can also remove people from segments with the remove_from_segments
key:
convertloop.people.create_or_update({
email: "[email protected]",
remove_from_segments: ["Segment 1"]
})
Learn more about the attributes of the create or update function
If you implemented a previous version of ConvertLoop's API using Tags, don't worry: all your Tags have already been automatically converted into Segments, and there is no action required in your code implementation to make them work.
To add or remove people from a segment using Java:
<dependency>
<groupId>co.convertloop</groupId>
<artifactId>convertloop-java</artifactId>
<version>0.1.0</version>
</dependency>
Or add the dependency in your build.gradle file:
dependencies {
compile 'co.convertloop:convertloop-java:0.1.0'
}
Convertloop convertloop = new Convertloop("your_app_id", "your_api_key", "v1");
add_to_segments
key:
HashMap contact = new HashMap();
contact.put("email", "[email protected]");
contact.put("add_to_segments", new String[] {"Segment 1", "Segment 2"});
convertloop.createOrUpdatePerson(contact);
You can also remove people from segments with the remove_from_segments
key:
HashMap contact = new HashMap();
contact.put("email", "[email protected]");
contact.put("remove_from_segments", new String[] {"Segment 1"});
convertloop.createOrUpdatePerson(contact);
Learn more about the attributes of the create or update function
If you implemented a previous version of ConvertLoop's API using Tags, don't worry: all your Tags have already been automatically converted into Segments, and there is no action required in your code implementation to make them work.
To add or remove a person from a segment using your command line (Linux or Mac) run the following command (replace the highlighted info with your own data):
$ curl -i -u app_id:api_key \
-X POST \
-H "Content-Type: application/json" \
-d '{ "email": "[email protected]", "add_to_segments": ["Segment 1", "Segment 2"] }' \
https://api.convertloop.co/v1/people
After making the request you should receive a JSON response similar to the following:
{
"pid" : "fe737ab6",
"user_id": null,
"email": "[email protected]",
"name": "",
"first_seen_at": null,
"last_seen_at":null,
"created_at":"2016-12-06T04:48:42.204Z",
"segments": ["Segment 1", "Segment 2"]
}
Learn more about the attributes of the create or update function
If you implemented a previous version of ConvertLoop's API using Tags, don't worry: all your Tags have already been automatically converted into Segments, and there is no action required in your code implementation to make them work.