Javascript SDK Example
### Full SDK Config
```
window.AptivadaAsyncInit = function(){
var myFrame = window.Aptivada.init({
//Required. The app id to be loaded
campaignId: 265042,
//Required. The campaign type to be loaded
campaignType: 'contest',
//Optional (default .aptivada-campaign) The selector the element to insert the iframe into
elem: ".aptivada-campaign",
//allows the iframe to be transparent. Background is set to white when false
transparent: false,
//optional (default 700px)
initialHeight: "700px", //the initial height to be applied to the iframe. The height will automatically adjust based on conditions within the campaign
//optional (default 100%)
width: "100%",
//optional (events will be invoked when certain events happen within the campaign)
events: {
//Events applicable to all campaigns
// ------------------------------------
//invoked immediately when our application loads
pageLoaded: function(e){
console.log('page loaded', e);
},
//Events applicable to all campaigns with a form
// ------------------------------------
//invoked when the user logs into the form
userLogin: function(e){
console.log('user logged in', e);
},
//invoked when the user logs out of the application
userLogout: function(e){
console.log('user logout', e);
},
//invoked when the user completes their entry
userCompleteEntry: function(e){
console.log('user complete entry', e);
},
//invoked when the user completes a field on the form
userCompleteField: function(e){
console.log('user complete field', e);
},
//invoked when the user views the last page
userViewLastPage: function(e){
console.log('user view last page', e);
},
//invoked after a user has successfully shared the campaign
userShare: function(e){
console.log('user share', e);
},
//Events applicable to gallery campaigns
// ------------------------------------
//invoked when a user votes on a gallery submission
userVote: function(e){
console.log('user vote', e)
},
//invoked when a user views a gallery submission
userViewSubmission: function(e){
console.log('user view submission', e);
},
//invoked after a user has successfully shared a gallery submission
userShareSubmission: function(e){
console.log('user share submission', e);
},
//Events applicable to survey/poll/quiz campaigns
// ------------------------------------
//invoked when a user finishes their initial info, and begins the survey
userBeginSurvey: function(e){
console.log('user begin survey', e);
},
//invoked when a user completes a question
userCompleteQuestion: function(e){
console.log('user complete question', e);
},
//invoked when a user completes the survey
userCompleteSurvey: function(e){
console.log('user complete survey', e)
},
//Events applicable to sport campaigns
// ------------------------------------
//invoked when a user makes a pick or removes a pick
userMakePick: function(e){
console.log('user make pick', e);
},
//Events applicable to countdown campaigns
// ------------------------------------
//invoked when a user successfully submits a keyword
userSubmitKeyword: function(e){
console.log('user submit keyword', e);
}
}
})
}
```
### Basic Embed Example
```
<script>
window.AptivadaAsyncInit = function(){
var myFrame = window.Aptivada.init({
campaignId: 265042,
campaignType: "contest",
events: {
userCompleteEntry: function(e){
console.log('user complete entry', e);
},
}
})
}
</script>
<script src="https://campaign.aptivada.com/sdk.js"></script>
<div class="aptivada-campaign"></div>