# Analytics Over Time (All Sites)
Source: https://developers.aimtell.com/api-reference/analytics/analytics-over-time-all-sites
/api-reference/misc-openapi.json get /prod/report/dashboard
Shows a report of specific metrics over time.
# Analytics Over Time (Specific Site)
Source: https://developers.aimtell.com/api-reference/analytics/analytics-over-time-specific-site
/api-reference/misc-openapi.json get /prod/report/dashboard/{id}
Shows a report of specific metrics over time.
# Get All API Push Campaigns
Source: https://developers.aimtell.com/api-reference/api-campaigns/get-all-api-push-campaigns
/api-reference/push-openapi.json get /prod/api-campaigns/{id}
Fetches the most recent API push campaigns for a site. Only recent campaigns are retained.
# Get API Campaign Results (By Day)
Source: https://developers.aimtell.com/api-reference/api-campaigns/get-api-campaign-results-by-day
/api-reference/push-openapi.json get /prod/api-campaigns/{idSite}/results
Fetches API Campaign Results (by Day)
# Introduction
Source: https://developers.aimtell.com/api-reference/introduction
Aimtell API Reference Documentation
Welcome to the Aimtell API documentation. This API allows you to programmatically manage your push notification campaigns, subscribers, segments, and more.
## Authentication
All API calls must pass the following header to authenticate the call.
| Header | Description |
| ----------------------- | -------------------------------------------------------- |
| X-Authorization-Api-Key | Generated within the Dashboard under Settings > API Key. |
# Get Alias Logs
Source: https://developers.aimtell.com/api-reference/logs/get-alias-logs
/api-reference/misc-openapi.json get /prod/log/alias/{id}
Fetches the Alias Log
# Get Attributes Logs
Source: https://developers.aimtell.com/api-reference/logs/get-attributes-logs
/api-reference/misc-openapi.json get /prod/log/attributes/{id}
Fetches Attributes Logs
# Get Event Logs
Source: https://developers.aimtell.com/api-reference/logs/get-event-logs
/api-reference/misc-openapi.json get /prod/log/events/{id}
Fetches the Event Log
# Get Notification Logs
Source: https://developers.aimtell.com/api-reference/logs/get-notification-logs
/api-reference/misc-openapi.json get /prod/log/notifications/{id}
Fetches the most recent notification logs for a site.
Note: this is a sample of notification logs; this will not return a comprehensive log of all notifications to all subscribers. Only recent notifications are retained, and on high volume sites that window can be short.
# Get Pageview Logs
Source: https://developers.aimtell.com/api-reference/logs/get-pageview-logs
/api-reference/misc-openapi.json get /prod/log/pageviews/{id}
Fetches Pageview Logs
# Create Campaign
Source: https://developers.aimtell.com/api-reference/manual-campaigns/create-campaign
/api-reference/push-openapi.json post /prod/campaigns/
Create a Campaign
# Delete Campaign
Source: https://developers.aimtell.com/api-reference/manual-campaigns/delete-campaign
/api-reference/push-openapi.json delete /prod/campaign/{id}
Delete a specific Campaign.
# Get All Manual Campaigns
Source: https://developers.aimtell.com/api-reference/manual-campaigns/get-all-manual-campaigns
/api-reference/push-openapi.json get /prod/campaigns/{id}
Enables you to fetch all MANUAL campaigns
# Get Manual Campaign
Source: https://developers.aimtell.com/api-reference/manual-campaigns/get-manual-campaign
/api-reference/push-openapi.json get /prod/campaign/{id}
Fetches a specific MANUAL Campaign
# Get Manual Campaign Clicks
Source: https://developers.aimtell.com/api-reference/manual-campaigns/get-manual-campaign-clicks
/api-reference/push-openapi.json get /prod/campaign/{id}/clicks
Enables you to fetch all clicks from a MANUAL campaign, broken down on a subscriber level.
# Get Manual Campaign Results (By Day)
Source: https://developers.aimtell.com/api-reference/manual-campaigns/get-manual-campaign-results-by-day
/api-reference/push-openapi.json get /prod/campaign/{id}/results
Fetches Manual Campaign Results (by Day)
Revenue for Monetized Campaigns is Included in Results
# Get Manual Campaign Shares
Source: https://developers.aimtell.com/api-reference/manual-campaigns/get-manual-campaign-shares
/api-reference/push-openapi.json get /prod/campaign/{id}/shared
Returns every site the manual campaign is shared with, along with the copied campaign ID on each site. Returns an empty array if the campaign is not shared.
# Share Manual Campaign
Source: https://developers.aimtell.com/api-reference/manual-campaigns/share-manual-campaign
/api-reference/push-openapi.json post /prod/campaign/{id}/shared
Shares this manual campaign with one or more additional sites. The campaign must target exactly one segment, and that segment must already be shared with every site listed here (see Share Segment). Edits to this campaign automatically propagate to the shared copies. To stop sharing with a site, delete the copied campaign on that site.
# Update Campaign
Source: https://developers.aimtell.com/api-reference/manual-campaigns/update-campaign
/api-reference/push-openapi.json put /prod/campaign/{id}
Updates a Specific Campaign
NOTE: When updating a campaign with A/B testing enabled, the version_b status param (1 or 2) must be included to ensure that parameters shared by A and B versions are updated in both campaigns (schedule_date, segments, automation, automation_end, push_ttl, auto_hide, tz_delivery, status). When updating the status of a campaign with A/B testing enabled, both the status param and the version_b status param must be set.
# Send Push Notification
Source: https://developers.aimtell.com/api-reference/one-off-notifications/send-push-notification
/api-reference/push-openapi.json post /prod/push/
Send a Push Notification
# Get Website Permissions
Source: https://developers.aimtell.com/api-reference/permissions/get-website-permissions
/api-reference/sites-openapi.json get /prod/site/{idSite}/permitted
Returns a list of users that have access to a site
# Grant Website Permissions
Source: https://developers.aimtell.com/api-reference/permissions/grant-website-permissions
/api-reference/sites-openapi.json post /prod/site/{idSite}/permitted
Grants access to a site to a registered user by email address
# Remove Website Permissions
Source: https://developers.aimtell.com/api-reference/permissions/remove-website-permissions
/api-reference/sites-openapi.json delete /prod/site/{idSite}/permitted
Removes access to a site to a registered user by uid
# Create Pixel
Source: https://developers.aimtell.com/api-reference/pixels/create-pixel
/api-reference/misc-openapi.json post /prod/pixels/{idSite}
Creates a cross domain tracking pixel
# Delete Pixel
Source: https://developers.aimtell.com/api-reference/pixels/delete-pixel
/api-reference/misc-openapi.json delete /prod/pixel/{id}
Deletes a cross domain tracking pixel by ID
# Get Pixel
Source: https://developers.aimtell.com/api-reference/pixels/get-pixel
/api-reference/misc-openapi.json get /prod/pixel/{id}
Fetches a cross domain tracking pixel by ID
# Get Pixels
Source: https://developers.aimtell.com/api-reference/pixels/get-pixels
/api-reference/misc-openapi.json get /prod/pixels/{idSite}
Fetches the cross domain tracking pixels for a website
# Update Pixel
Source: https://developers.aimtell.com/api-reference/pixels/update-pixel
/api-reference/misc-openapi.json post /prod/pixel/{id}
Updates a cross domain tracking pixel by ID
# Create Opt-in Prompt
Source: https://developers.aimtell.com/api-reference/prompts/create-opt-in-prompt
/api-reference/misc-openapi.json post /prod/prompts
Creates an opt-in prompt
# Create Opt-in Prompt Condition
Source: https://developers.aimtell.com/api-reference/prompts/create-opt-in-prompt-condition
/api-reference/misc-openapi.json post /prod/prompts/{idSite}/condition
Creates opt-in prompt condition
Note: If autoPrompt is set to true, seconds_delay, scroll_delay, and pages_delay should be set to NULL. If autoPrompt is set to false, provide a value for only one of the delay options, setting the other two to NULL (e.g. seconds_delay = 5, scroll_delay = NULL, pages_delay = NULL)
If values are set for multiple delay options, they will be evaluated in the following order: autoPrompt, scroll_delay, seconds_delay, pages_delay.
# Delete Opt-in Prompt
Source: https://developers.aimtell.com/api-reference/prompts/delete-opt-in-prompt
/api-reference/misc-openapi.json delete /prod/prompt/{id}
Deletes an opt-in prompt
# Delete Opt-in Prompt Condition
Source: https://developers.aimtell.com/api-reference/prompts/delete-opt-in-prompt-condition
/api-reference/misc-openapi.json delete /prod/prompts/{idSite}/condition/{id}
Deletes opt-in prompt condition by ID
# Get Default Opt-in Prompt Conditions
Source: https://developers.aimtell.com/api-reference/prompts/get-default-opt-in-prompt-conditions
/api-reference/misc-openapi.json get /prod/prompts/{idSite}/default-condition
Fetches the default opt-in prompt conditions for a website
# Get Opt-in Prompt
Source: https://developers.aimtell.com/api-reference/prompts/get-opt-in-prompt
/api-reference/misc-openapi.json get /prod/prompt/{id}
Fetches an opt-in prompt by ID
# Get Opt-in Prompt Condition
Source: https://developers.aimtell.com/api-reference/prompts/get-opt-in-prompt-condition
/api-reference/misc-openapi.json get /prod/prompts/{idSite}/condition/{id}
Fetches opt-in prompt condition by ID
# Get Opt-in Prompt Conditions
Source: https://developers.aimtell.com/api-reference/prompts/get-opt-in-prompt-conditions
/api-reference/misc-openapi.json get /prod/prompts/{idSite}/conditions
Fetches all opt-in prompt conditions for a website
# Get Opt-in Prompts
Source: https://developers.aimtell.com/api-reference/prompts/get-opt-in-prompts
/api-reference/misc-openapi.json get /prod/prompts/{idSite}
Fetches all opt-in prompts for a website
# Update Opt-in Prompt
Source: https://developers.aimtell.com/api-reference/prompts/update-opt-in-prompt
/api-reference/misc-openapi.json put /prod/prompt/{id}
Updates an opt-in prompt
# Update Opt-in Prompt Condition
Source: https://developers.aimtell.com/api-reference/prompts/update-opt-in-prompt-condition
/api-reference/misc-openapi.json put /prod/prompts/{idSite}/condition/{id}
Updates opt-in prompt condition by ID
Note: If autoPrompt is set to true, seconds_delay, scroll_delay, and pages_delay should be set to NULL. If autoPrompt is set to false, provide a value for only one of the delay options, setting the other two to NULL (e.g. seconds_delay = 5, scroll_delay = NULL, pages_delay = NULL)
If values are set for multiple delay options, they will be evaluated in the following order: autoPrompt, scroll_delay, seconds_delay, pages_delay.
When updating the default prompt condition, priority should be set to 0 and page should be set to *
# Create RSS Campaign
Source: https://developers.aimtell.com/api-reference/rss-campaigns/create-rss-campaign
/api-reference/push-openapi.json post /prod/rss-notifications/
Create a RSS Campaign
# Delete RSS Campaign
Source: https://developers.aimtell.com/api-reference/rss-campaigns/delete-rss-campaign
/api-reference/push-openapi.json delete /prod/rss-notification/{id}
Delete a specific RSS Campaign
# Get All RSS Campaigns
Source: https://developers.aimtell.com/api-reference/rss-campaigns/get-all-rss-campaigns
/api-reference/push-openapi.json get /prod/rss-notifications/{id}
Fetches All RSS Campaigns
# Get RSS Campaign
Source: https://developers.aimtell.com/api-reference/rss-campaigns/get-rss-campaign
/api-reference/push-openapi.json get /prod/rss-notification/{id}
Fetches a Specific RSS Campaign
# Get RSS Campaign Results (By Day)
Source: https://developers.aimtell.com/api-reference/rss-campaigns/get-rss-campaign-results-by-day
/api-reference/push-openapi.json get /prod/rss-notifications/{id}/results
Fetches RSS Campaign Results (by Day)
# Get RSS Campaign Shares
Source: https://developers.aimtell.com/api-reference/rss-campaigns/get-rss-campaign-shares
/api-reference/push-openapi.json get /prod/rss-notifications/{id}/shared
Returns every site the RSS campaign is shared with, along with the copied campaign ID on each site. Returns an empty array if the campaign is not shared.
# Share RSS Campaign
Source: https://developers.aimtell.com/api-reference/rss-campaigns/share-rss-campaign
/api-reference/push-openapi.json post /prod/rss-notifications/{id}/shared
Shares this RSS campaign with one or more additional sites. The campaign must target exactly one segment, and that segment must already be shared with every site listed here (see Share Segment). Edits to this campaign automatically propagate to the shared copies. To stop sharing with a site, delete the copied campaign on that site.
# Update RSS Campaign
Source: https://developers.aimtell.com/api-reference/rss-campaigns/update-rss-campaign
/api-reference/push-openapi.json put /prod/rss-notification/{id}
Update a RSS Campaign
# Create Segment
Source: https://developers.aimtell.com/api-reference/segments/create-segment
/api-reference/segments-openapi.json post /prod/segments/
Create a NEW Segment
# Delete Segment
Source: https://developers.aimtell.com/api-reference/segments/delete-segment
/api-reference/segments-openapi.json delete /prod/segment/{id}
Delete a specific Segment
# Get All Segments
Source: https://developers.aimtell.com/api-reference/segments/get-all-segments
/api-reference/segments-openapi.json get /prod/segments/{idSite}
Fetches all Segments for account
# Get Segment
Source: https://developers.aimtell.com/api-reference/segments/get-segment
/api-reference/segments-openapi.json get /prod/segment/{id}
Fetches a specific Segment
# Get Segment Counts Over Time
Source: https://developers.aimtell.com/api-reference/segments/get-segment-counts-over-time
/api-reference/segments-openapi.json get /prod/segment/{id}/results
Fetches a specific Segment
# Get Shared Segments
Source: https://developers.aimtell.com/api-reference/segments/get-shared-segments
/api-reference/segments-openapi.json get /prod/segment/{id}/shared
Returns every site this segment is shared with. Returns an empty array if the segment is not shared.
# Share Segment
Source: https://developers.aimtell.com/api-reference/segments/share-segment
/api-reference/segments-openapi.json post /prod/segment/{id}/shared
Shares this segment with one or more additional sites, creating a matching segment on each. Sharing a segment is a prerequisite for sharing any campaign that targets it. Segments using the following conditions cannot be shared: Exists In Segment, Does Not Exist In Segment, Manual Campaign Clicked, Triggered Campaign Clicked, RSS Campaign Clicked. Returns the full shared group, including sites shared previously.
# Update Segment
Source: https://developers.aimtell.com/api-reference/segments/update-segment
/api-reference/segments-openapi.json put /prod/segment/{id}
Update a Specific Segment
# Delete Website Custom Variable
Source: https://developers.aimtell.com/api-reference/settings/delete-website-custom-variable
/api-reference/sites-openapi.json delete /prod/site/variables/{id}
Deletes a Custom Variable for a Website by Name
# Get Website Code
Source: https://developers.aimtell.com/api-reference/settings/get-website-code
/api-reference/sites-openapi.json get /prod/site/code/{id}
Returns Aimtell push & website tracking code.
# Get Website Custom Variables
Source: https://developers.aimtell.com/api-reference/settings/get-website-custom-variables
/api-reference/sites-openapi.json get /prod/site/variables/{id}
Gets a Website's Custom Variables
# Get Website Keys
Source: https://developers.aimtell.com/api-reference/settings/get-website-keys
/api-reference/sites-openapi.json get /prod/site/{id}/keys
Gets a Website's VAPID or FCM Keys
Keys that are marked "is_primary" are the ones that will be currently used on the site for new subscribers.
If the results are empty, this means you are using legacy Aimtell keys. We advise you to generate your own VAPID keys within the dashboard.
# Get Website Settings
Source: https://developers.aimtell.com/api-reference/settings/get-website-settings
/api-reference/sites-openapi.json get /prod/site/{id}/settings
Get a Website's Tracking Settings
# Update Website Settings
Source: https://developers.aimtell.com/api-reference/settings/update-website-settings
/api-reference/sites-openapi.json post /prod/site/{id}/settings
Update a Website's Tracking Settings
# Upsert Website Custom Variable
Source: https://developers.aimtell.com/api-reference/settings/upsert-website-custom-variable
/api-reference/sites-openapi.json post /prod/site/variables/{id}
Creates or Updates a Custom Variable for a Website
# Upsert Website Keys
Source: https://developers.aimtell.com/api-reference/settings/upsert-website-keys
/api-reference/sites-openapi.json post /prod/site/{id}/keys/upsert
Update a Website's VAPID or FCM Keys
Note: this can directly impact your optin rate and/or push delivery. Only update these if you know what you are doing.
# Get Subscribers
Source: https://developers.aimtell.com/api-reference/subscribers/get-subscribers
/api-reference/segments-openapi.json get /prod/subscribers/{id}
Fetches subscribers for a given site. Optionally filter by segment or a specific subscriber.
# Track Subscriber Attribute
Source: https://developers.aimtell.com/api-reference/subscribers/track-subscriber-attribute
/api-reference/segments-openapi.json post /prod/subscriber
Track Subscriber Attribute
# Create Event Triggered Campaign
Source: https://developers.aimtell.com/api-reference/triggered-campaigns/create-event-triggered-campaign
/api-reference/push-openapi.json post /prod/event-campaigns/
Create an Event Triggered Campaign
# Delete Event Triggered Campaign
Source: https://developers.aimtell.com/api-reference/triggered-campaigns/delete-event-triggered-campaign
/api-reference/push-openapi.json delete /prod/event-campaign/{id}
Delete a specific Event Triggered Campaign
# Get All Event Triggered Campaigns
Source: https://developers.aimtell.com/api-reference/triggered-campaigns/get-all-event-triggered-campaigns
/api-reference/push-openapi.json get /prod/event-campaigns/{id}
Fetches All Event Triggered Campaigns
# Get Event Campaign Results (By Day)
Source: https://developers.aimtell.com/api-reference/triggered-campaigns/get-event-campaign-results-by-day
/api-reference/push-openapi.json get /prod/event-campaign/{id}/results
Fetches Event Campaign Results (by Day)
Revenue for Monetized Campaigns is Included in Results
# Get Event Triggered Campaign
Source: https://developers.aimtell.com/api-reference/triggered-campaigns/get-event-triggered-campaign
/api-reference/push-openapi.json get /prod/event-campaign/{id}
Fetches Event Triggered Campaign
# Get Triggered Campaign Shares
Source: https://developers.aimtell.com/api-reference/triggered-campaigns/get-triggered-campaign-shares
/api-reference/push-openapi.json get /prod/event-campaign/{id}/shared
Returns every site the triggered campaign is shared with, along with the copied campaign ID on each site. Returns an empty array if the campaign is not shared.
# Share Triggered Campaign
Source: https://developers.aimtell.com/api-reference/triggered-campaigns/share-triggered-campaign
/api-reference/push-openapi.json post /prod/event-campaign/{id}/shared
Shares this triggered campaign with one or more additional sites. The campaign must target exactly one segment, and that segment must already be shared with every site listed here (see Share Segment). Edits to this campaign automatically propagate to the shared copies. To stop sharing with a site, delete the copied campaign on that site.
# Update Event Triggered Campaign
Source: https://developers.aimtell.com/api-reference/triggered-campaigns/update-event-triggered-campaign
/api-reference/push-openapi.json put /prod/event-campaign/{id}
Update an Event Triggered Campaign
# Get User
Source: https://developers.aimtell.com/api-reference/users/get-user
/api-reference/openapi.json get /prod/user/
# Update User
Source: https://developers.aimtell.com/api-reference/users/update-user
/api-reference/openapi.json put /prod/user/
# Add Website
Source: https://developers.aimtell.com/api-reference/websites/add-website
/api-reference/sites-openapi.json post /prod/sites/
Add a Website to Account
# Delete Website
Source: https://developers.aimtell.com/api-reference/websites/delete-website
/api-reference/sites-openapi.json delete /prod/site/{id}
Delete a specific Website.
# Get All Websites
Source: https://developers.aimtell.com/api-reference/websites/get-all-websites
/api-reference/sites-openapi.json get /prod/sites/
Grabs all active websites for account.
# Get Website
Source: https://developers.aimtell.com/api-reference/websites/get-website
/api-reference/sites-openapi.json get /prod/site/{id}
Returns information about a website
# Update Website Details
Source: https://developers.aimtell.com/api-reference/websites/update-website-details
/api-reference/sites-openapi.json put /prod/site/{id}
Update a Website's Name or Icon
# Get Welcome Campaign
Source: https://developers.aimtell.com/api-reference/welcome-notifications/get-welcome-campaign
/api-reference/push-openapi.json get /prod/site/{idSite}/welcome
Fetches the Welcome Campaign for a specific website
# Get Welcome Campaign Results (By Day)
Source: https://developers.aimtell.com/api-reference/welcome-notifications/get-welcome-campaign-results-by-day
/api-reference/push-openapi.json get /prod/welcome-notifications/{id}/results
Fetches Welcome Campaign Results (by Day)
# Update Welcome Campaign
Source: https://developers.aimtell.com/api-reference/welcome-notifications/update-welcome-campaign
/api-reference/push-openapi.json post /prod/site/{idSite}/welcome/upsert
Update a Welcome Campaign for a Specific Website
# Callback Functions
Source: https://developers.aimtell.com/javascript-api/callback-functions
Javascript callback functions for Aimtell
Callback functions work in the opposite direction to the rest of the Javascript API: instead of you calling Aimtell, Aimtell calls you. You define these functions on your page, and the Aimtell script runs them when the matching event happens: the script finishing loading, or a visitor granting, ignoring or denying push permission.
Each one is optional. If you haven't defined it, nothing happens.
Define them as regular global functions using the exact names below, and make sure they exist before the Aimtell script loads.
***
## Aimtell Ready
```javascript theme={null}
_aimtellReady()
```
**Description:** Called when aimtell script has finished loading.
### Example
```javascript theme={null}
function _aimtellReady(){
alert("Everything is loaded!");
}
```
***
## Permission Granted
```javascript theme={null}
_aimtellPermissionGranted()
```
**Description:** Called after website visitor has granted push notification permissions.
### Example
```javascript theme={null}
function _aimtellPermissionGranted(){
alert("Thanks, you're now subscribed!");
}
```
***
## Permission Ignored
```javascript theme={null}
_aimtellPermissionIgnored()
```
**Description:** Called after website visitor has ignored push notification permissions. (clicking "x" on the request dialog)
### Example
```javascript theme={null}
function _aimtellPermissionIgnored(){
alert("Oh no, you ignored me!");
}
```
***
## Permission Denied
```javascript theme={null}
_aimtellPermissionDenied()
```
**Description:** Called after website visitor has denied push notification permissions.
### Example
```javascript theme={null}
function _aimtellPermissionDenied(){
alert("Oh no, you denied me!");
}
```
# Generic Functions
Source: https://developers.aimtell.com/javascript-api/generic-functions
Javascript generic functions for Aimtell
## Synchronous vs. Promise-Based Functions
Some functions return a value immediately, while others return a **promise** and must be awaited (or chained with `.then()`). If you use a promise-based function directly, you get back a `Promise` object instead of the value.
Functions that return a value immediately:
* `_aimtellCheckPermissions()`
* `_aimtellSupportsPush()`
* `_aimtellPrompt()`
* `_aimtellForcePrompt()`
Functions that return a promise:
* `_aimtellGetSubscriberID()`
* `_aimtellGetPushToken()`
* `_aimtellGetSubscriberIDFromToken(token)`
* `_aimtellGetSubscriberAttributes()`
* `_aimtellGetNotifications()`
* `_aimtellMarkNotificationsRead(timestamp)`
* `_aimtellMarkNotificationsUnread(timestamp)`
* `_aimtellDeleteNotifications(timestamp)`
```javascript theme={null}
// Incorrect - logs a Promise object, not the subscriber id
console.log(_aimtellGetSubscriberID());
// Correct - with .then()
_aimtellGetSubscriberID().then(function(subscriberID){
console.log(subscriberID);
});
// Correct - with async/await
async function logSubscriberID(){
var subscriberID = await _aimtellGetSubscriberID();
console.log(subscriberID);
}
```
Aimtell functions are only available once the script has finished loading. If you're calling them on page load, do it from inside [`_aimtellReady()`](/javascript-api/callback-functions#aimtell-ready).
***
## Check Permissions
```javascript theme={null}
_aimtellCheckPermissions()
```
**Description:** Checks visitor's push notification permissions
**Params:** N/A
**Response:** `(str)` - `granted`, `default` or `denied`
### Example
```javascript theme={null}
console.log(_aimtellCheckPermissions()); // "granted", "default" or "denied"
```
***
## Supports Push
```javascript theme={null}
_aimtellSupportsPush()
```
**Description:** Checks to see if visitor's browser supports push notifications
**Params:** N/A
**Response:** `(boolean)`
### Example
```javascript theme={null}
console.log(_aimtellSupportsPush()); // true or false
```
***
## Get Subscriber ID
```javascript theme={null}
_aimtellGetSubscriberID()
```
**Description:** Grabs the active visitor's subscriber id. If none exists, one is generated.
**Params:** N/A
**Response:** promise, `(str)` subscriber id
### Example
```javascript theme={null}
_aimtellGetSubscriberID().then(function(subscriberID){
console.log(subscriberID);
});
```
Example response:
```javascript theme={null}
"f47ac10b-58cc-4372-a567-0e02b2c3d479"
```
***
## Get Push Token
```javascript theme={null}
_aimtellGetPushToken()
```
**Description:** Pulls the device push token from the current visitor. This is delivered as a javascript promise.
**Params:** N/A
**Response:** promise, `(str)` device token
### Example
```javascript theme={null}
_aimtellGetPushToken().then(function(token){
console.log(token);
});
```
Example response:
```javascript theme={null}
"cJ4h1Zq0TnE:APA91bGx7vN2mQd8sYk..."
```
Resolves to `null` if the visitor isn't subscribed or the browser doesn't support push.
***
## Get Subscriber ID From Token
```javascript theme={null}
_aimtellGetSubscriberIDFromToken(token)
```
**Description:** Grabs visitors subscriber id based on push token
**Params:**
* `token` - required. browser push token
**Response:** promise, `(obj)` result, uid
### Example
```javascript theme={null}
_aimtellGetSubscriberIDFromToken(token).then(function(result){
console.log(result);
});
```
Example response:
```json theme={null}
{
"result": "success",
"uid": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
}
```
If no subscriber matches the token:
```json theme={null}
{
"result": "error",
"message": "No subscriber found matching token."
}
```
***
## Get Subscriber Attributes
```javascript theme={null}
_aimtellGetSubscriberAttributes()
```
**Description:** Grabs current website subscriber's attributes.
**Params:** N/A
**Response:** promise, `(obj)` with `idSite`, `subscriber_uid` and `custom_attributes`. `custom_attributes` is an object of your tracked attribute name/value pairs, and is empty if none have been set.
**Note:** As custom attributes may contain information which an Aimtell website owner may not want easily viewable, this function by default is locked as a security measure. You must specifically request our team to unlock it for your account.
### Example
```javascript theme={null}
_aimtellGetSubscriberAttributes().then(function(response){
console.log(response);
});
```
Example response:
```json theme={null}
{
"idSite": "20531",
"subscriber_uid": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"custom_attributes": {
"age": "35",
"name": "david"
}
}
```
***
## Show Push Prompt
```javascript theme={null}
_aimtellPrompt()
```
**Description:** If custom push prompt exists, show it, else load native push prompt
**Params:** N/A
**Response:** `null`
### Example
```javascript theme={null}
_aimtellPrompt();
```
***
## Force Push Prompt
```javascript theme={null}
_aimtellForcePrompt()
```
**Description:** Force shows the custom optin, even if previously denied.
**Params:** N/A
**Response:** `null`
"Previously denied" refers to the visitor dismissing your custom optin. If the visitor has already granted or denied permission at the *browser* level, this function does nothing. Browser permissions can only be changed by the visitor in their browser settings.
### Example
```javascript theme={null}
_aimtellForcePrompt();
```
***
## Get Notifications
```javascript theme={null}
_aimtellGetNotifications()
```
**Description:** Returns the subscriber's notifications, most recent first.
**Params:** N/A
**Response:** promise, `(array)` of notification objects with the following fields:
* `title` - notification title
* `body` - notification body
* `icon` - icon URL
* `link` - destination URL
* `read` - `(boolean)` `true` if read, `false` if unread
* `timestamp` - used to target a single notification in the functions below
### Example
```javascript theme={null}
_aimtellGetNotifications().then(function(notifications){
console.log(notifications);
});
```
Example response:
```json theme={null}
[
{
"title": "Your order has shipped",
"body": "Track your package for delivery updates.",
"icon": "https://example.com/icon.png",
"link": "https://example.com/orders/1234",
"read": false,
"timestamp": 1754838000
},
{
"title": "Weekend sale starts now",
"body": "20% off everything through Sunday.",
"icon": "https://example.com/icon.png",
"link": "https://example.com/sale",
"read": true,
"timestamp": 1754751600
}
]
```
Returns an empty array if the subscriber has no notifications.
***
## Mark Notifications Read
```javascript theme={null}
_aimtellMarkNotificationsRead(timestamp)
```
**Description:** Marks notifications as read. Pass a `timestamp` to mark a single notification, or call with no arguments to mark all notifications as read.
**Params:**
* `timestamp` - optional. The `timestamp` value from a `_aimtellGetNotifications()` response item. Pass it through unchanged.
**Response:** promise, `(obj)` `{ updated: }`
### Example
```javascript theme={null}
// Mark all notifications as read
_aimtellMarkNotificationsRead().then(function(result){
console.log(result); // { updated: 3 }
});
// Mark a single notification as read
_aimtellMarkNotificationsRead(1754838000).then(function(result){
console.log(result); // { updated: 1 }
});
```
***
## Mark Notifications Unread
```javascript theme={null}
_aimtellMarkNotificationsUnread(timestamp)
```
**Description:** Marks notifications as unread. Pass a `timestamp` to target one, or omit to mark all notifications as unread.
**Params:**
* `timestamp` - optional. The `timestamp` value from a `_aimtellGetNotifications()` response item. Pass it through unchanged.
**Response:** promise, `(obj)` `{ updated: }`
### Example
```javascript theme={null}
// Mark all notifications as unread
_aimtellMarkNotificationsUnread().then(function(result){
console.log(result); // { updated: 3 }
});
// Mark a single notification as unread
_aimtellMarkNotificationsUnread(1754838000).then(function(result){
console.log(result); // { updated: 1 }
});
```
***
## Delete Notifications
```javascript theme={null}
_aimtellDeleteNotifications(timestamp)
```
**Description:** Deletes notifications. Pass a `timestamp` to delete a single notification, or omit to delete all of the subscriber's notifications.
**Params:**
* `timestamp` - optional. The `timestamp` value from a `_aimtellGetNotifications()` response item. Pass it through unchanged.
**Response:** promise, `(obj)` `{ deleted: }`
### Example
```javascript theme={null}
// Delete all notifications
_aimtellDeleteNotifications().then(function(result){
console.log(result); // { deleted: 3 }
});
// Delete a single notification
_aimtellDeleteNotifications(1754838000).then(function(result){
console.log(result); // { deleted: 1 }
});
```
# Tracking Functions
Source: https://developers.aimtell.com/javascript-api/tracking-functions
Javascript API tracking functions for Aimtell
Tracking functions send information about the current visitor to Aimtell: who they are, what they did, and what you know about them. That data is what you later build segments from and target campaigns against.
All three share the same `_at.track(type, params)` signature, where `type` is `alias`, `event` or `attribute`.
You can call these at any point on the page. Calls made before the Aimtell script finishes loading are queued and processed once it's ready, and calls made before the visitor has granted push permission are held and sent after they subscribe, so nothing is lost by tracking early.
***
## Alias Tracking
Associates an alias against the push subscriber for simplified server-side tracking.
```javascript theme={null}
_at.track("alias", {"user" : "name or id", "email" : "email" });
```
**Description:** Associates an alias against the push subscriber for simplified server-side tracking
You may pass the `user` field and/or the `email` field. All emails are automatically hashed.
### Example
```javascript theme={null}
_at.track("alias", {"user" : "jack17"});
```
***
## Event Tracking
Tracks an event against the current subscriber.
```javascript theme={null}
_at.track("event", {"category" : "A", "action" : "B", "label": "C", "value" : D });
```
**Description:** Tracks an event against the current subscriber
`category` & `action` are required. `label` and `value` are optional.
### Example
```javascript theme={null}
_at.track("event", {
"category" : "Item",
"action" : "Purchased",
"label": "Blue Shoes",
"value" : 33
});
```
***
## Attribute Tracking
Tracks custom attribute(s) against the subscriber.
```javascript theme={null}
_at.track("attribute", {"attribute" : "value"});
```
**Description:** Tracks custom attribute(s) against the subscriber
### Example
```javascript theme={null}
_at.track("attribute", {"age" : "35", "name":"david"});
```