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.


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-aeelements 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.

Parameters

service : The name of a social service.

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

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

Example:

<a href="#" onclick="aeJS.trigger.authenticate(‘twitter’,’login’,‘<a href="http://someurl.com%E2%80%99);%22>LOGOUT</a" rel="nofollow noopener noreferrer" target="_blank">http://someurl.com’);">LOGOUT</a</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.

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.

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.

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.


aeJS.trigger.popup

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.

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.

Parameters

id: The Service ID value for the email/password login. For example, the ID returned in the ‘Services’ node or the 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.

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. 

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. 

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. 

Parameters

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


aeJS.get.flow

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


aeJS.get.user

Returns current user object.



How did we do?