Simple Participant Registration
Create your first Participant registration flow!
This code is an example of how to use the Viral Loops Javascript SDK to participate in a Viral Loops campaign.
<script>
// Participate in Viral Loops campaign
async function participateInViralLoops(user) {
// Get campaign by ID
const campaign = await ViralLoops.getCampaign("your Campaign ID");
// Identify user in campaign
console.log('[Viral Loops] Identifying...', user);
const response = await campaign.identify(user).catch(error => {
console.error("[Viral Loops] Participation error", error);
});
// Log response
if (response.isNew) {
console.log('[Viral Loops] ✅ Participation completed!');
} else {
console.log('[Viral Loops] ✅ Identified participant!');
}
}
// User object with first name, last name, and email
const user = {
firstname: "Jimi",
lastname: "Hendrix",
email: "[email protected]"
};
participateInViralLoops(user);
</script>
Updated over 1 year ago