swellAPI.getActiveCampaigns()
This method returns an array containing all active campaigns you are running as well as the logged in customer’s status toward each one. You can use this method to build custom interface around your campaigns.
$(document).on("swell:setup", function(){
var activeCampaigns = swellAPI.getActiveCampaigns();
activeCampaigns.forEach(function(campaign){
// render each campaign
});
})
backgroundImageUrl: "https://paperclip-cloudfront.swellrewards.com/images/images/4870_1530799978.original.png?1530799978"
campaignTiers: []
ctaText: "Take me there"
customerActionsCompleted: 0
customerCanParticipate: true
customerCompleted: false
customerCompletions: 0
customerDaysUntilNextAction: undefined
customerDaysUntilNextParticipation: undefined
customerDaysUntilNextReward: undefined
customerHoursUntilNextAction: undefined
customerHoursUntilNextParticipation: undefined
customerHoursUntilNextReward: undefined
customerMinutesUntilNextAction: 0
customerMinutesUntilNextParticipation: 0
customerMinutesUntilNextReward: 0
details: "Give your friend $15 off their first purchase of $100+ and get $15 in Drops."
expiresAt: null
icon: "fa-heart"
id: 377555
rewardPercentage: 10
rewardPoints: 300
rewardText: "15"
rewardType: "fixed_amount"
title: "Refer a friend"
__proto__: Object
Campaign Object
Attribute | Type | Description |
---|---|---|
id | int | The campaign id, useful for setting up click handlers or triggering custom actions |
ctaText | string | The call to action button text set in Swell admin |
details | string | The description of the campaign set in the Swell admin |
title | string | The one line description of the campaign set in Swell admin |
expiresAt | datetime | Campaign expiration if campaign is running for limited time |
icon | string | The Font Awesome icon class (or image url) set for this campaign |
rewardText | string | Description of the reward the customer will receive for completion |
customerActionsCompleted | int | The number of actions completed (if applicable) |
customerCanParticipate | boolean | Based on the rules, can this customer participate right now |
customerCompleted | boolean | Flag indicating whether the campaign has been completed or not |
customerCompletions | int | The number of times the customer has completed the campaign |
customerMinutesUntilNextParticipation | int | The number of minutes left until the customer can participate in the campaign again |
customerHoursUntilNextParticipation | int | The number of hours left until customer can participate in the campaign again |
customerDaysUntilNextParticipation | int | The number of days left until customer can participate in the campaign again |
backgroundImageURL | string | The hosted URL of the image associated with the campaign in the Swell admin |
rewardType | string | The type of reward/redemption associated with the campaign. |
rewardPercentage | int | Shows progress on Goal Spend/Punch Card campaign |
rewardPoints | int | The number of points associated with completing this campaign |
campaignTiers | array | This attribute will populate if there's a tier restriction on the campaign |