Appreciation Engine

Open navigation

AE JS Methods & Triggers Reference


In addition to the data attributes, the AE JS framework offers a number of method calls that control the authentication flow. These can triggered by developers directly.


This article provides a reference of the available methods.






Table of Contents







aeJS.trigger.attach


Attach AE functionality to any element in the DOM with the proper ae-data attributes applied. For example, the data-ae-register-window data attribute. This is recommended in cases where elements may be generated or injected after the framework has loaded.


Passing in a DOM element reference will ensure that only that element has the functionality attached, otherwise it is applied to all data-ae elements on the page.



Parameters


element: An element in the DOM.






aeJS.trigger.authenticate


Authenticate the current visitor with specified service. Returns the provided URL. This trigger must be attached to a user action, such as a click or select. Check for call results using the onLogin or onUser events.



Parameters


service : The name of a social service.


type : login, register or auth. The default value is register.


Important

Note: auth is only recommended for use when an existing member session is active. Future releases will enforce this behavior.


return: A URL to return after the action. The default value is the current URL.


Example:

<a href="#" onclick="aeJS.trigger.authenticate('twitter','login','http://someurl.com')"> 
    LOGOUT 
</a> 






aeJS.trigger.login


Initiate a valid AE session for the user linked to the given access token. This can be used to log in users from third-party services that retrieve a valid access token via their own AE integration. For example, a mobile app. Check for call results using the onLogin event.



Parameters


accesstoken: A valid access token, retrieved via the AE JS framework or the AE REST API.






aeJS.trigger.flow


Initiate the authentication flow. This shows the authentication screen via modal or browser redirect.



Parameters


type : login or register. The default value is register.


return : A URL to return after the action. The default value is the current URL.


Example:

authDelegate.login = function(delegate) { 
  aeJS.trigger.flow(); 
};






aeJS.trigger.logout


Logs out the current user. Clears current AE session and local user object. Triggers onLogout handlers to handle next steps. Check for call results using the onLogout event.


Example:

<a href="#" onclick="aeJS.logout();">
    Log out
</a>






aeJS.trigger.optin


Sends an optin event to AE. User can opt-in to global-, brand-, or segment-based lists. Check for call results using the onOptin event.



Parameters


brandid : Optional. Provide if user is subscribing to specific brand list. Leave blank for global list.


segmentid : Optional. Provide if user is subscribing to specific segment list. Leave blank for global or brand list.


record : Boolean value to indicate whether the updated user record should be returned as part of the


onOptin : event. The default value is false. Note that returning the record slows the response time.







Opens the AE popup window (but not a modal), so that actions, such as form submits, can be submitted there. This is intended to be used by developers who may need to access this for custom-built authentication flows.



Parameters


url






aeJS.trigger.remove


Removes specified service from currently attached services for current user. Check for call results using the onFlow event.



Parameters


service : A social service


return : A URl to return after the action. The default value is the current URL.






aeJS.trigger.reset_password


Updates the password for a user’s email/password registration service. Check for call results using the onPasswordReset event.



Parameters


id : The Service ID value for the email/password login. For example, the ID returned in the ‘Services’ node or the span style="background-color: rgb(239, 239, 239); color: rgb(226, 80, 65);">MemberServiceID returned in onEmailVerify.


email : Email address to reset password for.


password : The new password to use.






aeJS.trigger.send_activity


Sends and records activity indicated by id parameter. The activity must be a custom activity as defined via the AE dashboard or REST API in order to generate its associated id for use. Check for call results using the onActivitySent event.



Parameters


id : The custom activity ID as defined in Appreciation Engine.


data : A string or object that describes the activity event.


marker : Optional. The unique marker for this event. This is used to limit repeated actions.


record : A boolean value to indicate whether the created activity record should be returned as part of the onActivitySent event. The default value is false. Note that returning the record slows the response time.






aeJS.trigger.send_verify_email


Initiates manual/custom email verification process. An email will be sent to the user with return URL specified to click for verification. Check for call results using the onEmailVerify event.



Parameters


returnURL : The URL user will be directed to for verification. This will have step=send-email-ok attribute appended. The page will fire the onEmailVerify event.


email : The email address to send a verification email to.


message : An object containing message parts for email verification template.


Here's an example of a message object:

{
    'subject':'Email Subject', 
    'body':'Body text in email', 
    'label': 'Return link label'
}






aeJS.trigger.submit


Triggers submission of the indicated data-ae-register-form. This is passed as a DOM element.



Parameters


data-ae-register-form






aeJS.trigger.verify_email


Initiates default email verification flow with modals or redirect. An email will be sent to user with a return URL specified to click for verification. Check for call results using the onFlow event.



Parameters


returnURL : A URL user will be directed to for verification. This will have the step=verify-email-ok attribute appended.






aeJS.trigger.verify_reset_password


Initiates default password reset flow with modals or redirect. An email will be sent to user with a return URL specified to click for verification. Check for call results using the onFlow event.



Parameters


returnURL : A URL user will be directed to for verification. This will have step=reset-password-ok appended.






aeJS.trigger.activity_sharing


Set the activity sharing flag for a member's service. When activity sharing is disabled the member cannot be used for analytics or segmentation. The member's credentials can still be used by developers to make calls to the relevant external APIs (eg. twitter, spotify, etc). Check for call results using the onActivitySharing event.



Parameters


serviceid : The service id (i.e twitter, spotify, etc) to set activity sharing flag for.


enable : Boolean value to indicate whether data sharing is on/off for this member service.






aeJS.trigger.get_flow


Returns current flow state. This uses the same format state provided in the onFlow/code> event.






aeJS.trigger.get_user


Returns current user object.



Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.