Skip to main content

Create A Custom Login Page

This article covers how to use the AgencyAnalytics API to build your own custom login page for your website or CRM.

Written by AgencyAnalytics Team

Custom Login Page

By using the AgencyAnalytics API, you can build your own custom login page on your website. You can find all the API information you need in the API Playground.

Creating your own custom login page lets you:

  • Tie your login page into your existing website or CRM (client relationship management) software

  • Style your login area to match your exact design specifications

  • Change how your clients log in and which page they land on afterward


Before You Start

You'll need your AgencyAnalytics API key to make API requests. You can find your API key under your profile settings. For more details on finding and using your key, see this resource article.

Because a custom login page depends on how your own website is built, our Support team is not able to help troubleshoot custom API implementations. We recommend hiring a professional web developer to build and maintain this integration for you.


How To Create A Custom Login Page

Building a functioning custom login page involves five steps. Each step is explained in more detail below.

Step 1: Authenticate the user on your end.

Step 2: Get the user list from your AgencyAnalytics account using the API.

Step 3: Match the user ID.

Step 4: Generate the login grant for that user ID via the API.

Step 5: Redirect to the URL provided by the API response.


Step 1: Authenticate the User on Your End

This step depends entirely on how your existing website is set up and which CMS (content management system) it uses.

For example, in a WordPress CMS, you can use the wp_authenticate function to check whether the login is valid. If the user logs in successfully, you can continue.

wp_authenticate($username, $password);

Step 2: Get The User List From Your AgencyAnalytics Account Using The API

In February 2025, we changed the language from "Campaign" to "Client" across AgencyAnalytics. To keep things running smoothly for agencies using the API, asset names like campaign_id or campaign_access won't be changed from campaign to client.

Perform a request to list all users.

{
"provider": "agency-analytics-v2",
"asset": "user",
"operation": "read",
"fields": [
"id",
"campaign_id",
"date_created",
"date_modified",
"email",
"first_name",
"last_name",
"role",
"campaign_access",
"status",
"account_id"
],
"sort": [
{
"id": "desc"
}
],
"offset": 0,
"limit": 50
}

The response will be in JSON format and will be similar to the following:

 {
"metadata": {
"total_pages": 1,
"total_records": 2
},
"data": [
{
"id": 123,
"date_created": "2015-03-30 10:06:24",
"email": "bob@myagency.com",
"username": "bob@myagency.com",
"password": null,
"first_name": "Bob",
"last_name": "Doe",
"role": "client",
"campaign_access": "restricted",
"account_id": 1
},
{
"id": 124,
"date_created": "2015-03-30 10:06:25",
"email": "alice@myagency.com",
"username": "alice@myagency.com",
"password": null,
"first_name": "Alice",
"last_name": "Citizen",
"role": "client",
"campaign_access": "restricted",
"account_id": 1
}
]
}

Step 3: Match The User ID

Here, you will need to match the username entered in your form with the username in the user list from the API response.

It's recommended to use email addresses as usernames because AgencyAnalytics uses them, and therefore, they will match up quite easily. However, this will not be possible in all circumstances (depending on how your customer database is set up).

Step 4: Generate The Login Grant For That User ID Via The API

Now that the user ID (123) has been retrieved for the user attempting to log in, you can generate the login grant via the API.

{
"provider": "agency-analytics-v2",
"asset": "login-grant",
"operation": "create",
"rows": [
{
"user_id": "123"
}
]
}

Response:

{
"metadata": {
"total_pages": 1,
"total_records": 1
},
"data": {
"token": "tkn.7bf94c2ks9f2e7d86174a4b3fc01c5ae",
"time": "2015-04-13 16:34:57",
"login_url": "http:\/\/reports.myagency.com\/login-token\/tkn.c6e1768b8e01ddwq2461ace8886b",
"user_id": 123,
"origin_user_id": 1
}
}

Step 5: Redirect To The URL Provided By The API Response

With that API response, you can extract the login URL.

http://reports.myagency.com/login-token/tkn.c6e1768b8e01ddwq2461ace8886b

Finally, the user can be sent to their Client area by using one of the many redirect methods.


💬 Need additional help?

If you have any questions, please contact our friendly support team by following these instructions! We're available 24/5 to help 😄

Did this answer your question?