How to trigger a campaign programmatically

You can set up a campaign to be triggered programmatically (requires coding).

How to set it up

While you are editing your campaign in the editor, go to the "Behavior" section.

Set the trigger to "Manual".

Don't forget to save your campaign.

Trigger the campaign 

The campaign will be triggered when the triggerPlugin() function is called.
Once triggered programmatically, all targeting rules apply and the campaign flow is as usual (eg. success message or any other flow you set up).
The function is as follows:
socital.triggerPlugin(pluginID, callback)

*pluginID is your campaign's ID
An easy way to find your campaign's ID, is while you are editing the campaign in the editor, it is the last string in the URL.

Example request

socital.triggerPlugin("5878d05ea253ce85c139653d",function(err,data){if (err) {console.log('Error: '+err)} else {console.log(JSON.stringify(data))}})

In case of a successful subscription, the data parameter in the callback function will contain an object of the following type:

{
  "success":true,
   "socialUser":"{\"id\":\"...\",\"name\":\"...\",\"email\":\"...\",\"provider\":\"linkedin\",\"pluginID\":\"5878d05ea253ce85c139653d\"}"
}

In case of an unsuccessful login, the err parameter in the callback function will contain an object of the following type:

{
success: false,
error: "Authentication error."
}

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us