Sending an Email automation with multiple parameters

I’m trying to send a “your product is ready” email notification to users with multiple parameters with the event tracking API. At the moment, it seems that it’s only possible to send one parameter, where I actually need 5 different ones, the name of the product, 3 numerical values, and a link to visit the product details. I was wondering if this is possible to do with the event tracking API, or if there is an alternative tool I can use to accomplish this.

Thanks!

1 Like

Event tracking can do a lot, but this is an almost perfect use case for custom objects. This will make tracking orders and sending multiple values easy.

Here’s how you do it:

1) Set up your schema (you only make this call once)

Following the information you provided, I want to create a custom object on a contact that tracks 5 different data points, that are linked:

  1. product name (text)
  2. product price (number)
  3. product link (text)
  4. order number (number)
  5. product link

First I have to create the “schema” to hold this data. The POST to https://{{yourAccountName}}.api-us1.com/api/3/customObjects/schemas looks like below. You can see where I create the fields and mark them as “number” or “text”:

{
    "schema": {
        "labels": {
            "singular": "Website Order",
            "plural": "Website Orders"
        },
        "slug": "orders",
        "description": "Example of custom objects for tracking orders",
        "fields": [
            {
                "id": "order-price",
                "slug": "order-price",
                "labels": {
                    "singular": "Order Price",
                    "plural": "Order Prices"
                },
                "type": "number",
                "scale": 0,
                "isRequired": false
            },
            {
                "id": "order-number",
                "slug": "order-number",
                "labels": {
                    "singular": "Order Number",
                    "plural": "Order Numbers"
                },
                "type": "number",
                "scale": 0,
                "isRequired": false
            },
            {
                "id": "order-count",
                "slug": "order-count",
                "labels": {
                    "singular": "Order Count",
                    "plural": "Order Count"
                },
                "type": "number",
                "scale": 0,
                "isRequired": false
            },
            {
                "id": "product-name",
                "slug": "product-name",
                "labels": {
                    "singular": "Product name",
                    "plural": "Product names"
                },
                "type": "text",
                "scale": 0,
                "isRequired": false
            },
            {
                "id": "product-link",
                "slug": "product-link",
                "labels": {
                    "singular": "Product link",
                    "plural": "Product links"
                },
                "type": "text",
                "scale": 0,
                "isRequired": false
            }
        ],
        "relationships": [
            {
                "id": "primary-contact",
                "labels": {
                    "singular": "Primary Contact",
                    "plural": "Primary Contacts"
                },
                "description": "Primary contact to this order",
                "namespace": "contacts",
                "hasMany": false
            }
        ]
    }
}

This first call returns the schema id we will be using to populate/track orders for our contacts.

When we made the POST call above, we got this back:

{
    "schema": {
        "id": "968535b7-9b8f-4398-af54-37611defcf89",
        "slug": "orders",
        "visibility": "private",
        "labels": {
            "singular": "Website Order",
            "plural": "Website Orders"
        },
        "description": "Example of custom objects for tracking orders",
        "createdTimestamp": "2022-08-15T19:10:53.865596638Z",
        "updatedTimestamp": "2022-08-15T19:10:53.865596638Z",
        "fields": [
            {
                "id": "order-price",
                "labels": {
                    "singular": "Order Price",
                    "plural": "Order Prices"
                },
                "type": "number",
                "required": false,
                "scale": 0,
                "inherited": false
            },
            {
                "id": "order-number",
                "labels": {
                    "singular": "Order Number",
                    "plural": "Order Numbers"
                },
                "type": "number",
                "required": false,
                "scale": 0,
                "inherited": false
            },
            {
                "id": "order-count",
                "labels": {
                    "singular": "Order Count",
                    "plural": "Order Count"
                },
                "type": "number",
                "required": false,
                "scale": 0,
                "inherited": false
            },
            {
                "id": "product-name",
                "labels": {
                    "singular": "Product name",
                    "plural": "Product names"
                },
                "type": "text",
                "required": false,
                "scale": 0,
                "inherited": false
            },
            {
                "id": "product-link",
                "labels": {
                    "singular": "Product link",
                    "plural": "Product links"
                },
                "type": "text",
                "required": false,
                "scale": 0,
                "inherited": false
            }
        ],
        "icons": {
            "default": "https://d226aj4ao1t61q.cloudfront.net/n9mayqo2d_customobject.png"
        },
        "relationships": [
            {
                "id": "primary-contact",
                "labels": {
                    "singular": "Primary Contact",
                    "plural": "Primary Contacts"
                },
                "description": "Primary contact to this order",
                "namespace": "contacts",
                "hasMany": false,
                "inherited": false
            }
        ]
    }
}

You can see the schema that was created has the id 968535b7-9b8f-4398-af54-37611defcf89 we will be using that id for future calls to populate order data.

1 Like

2. Populate custom data as orders come in

Let’s say we have this order:

Email: user@test.com
Order Price: $14.00
Order Number: 3552
Order Count: 2
Product Name: Green Hat
Produc Link: https://www.example.com/greenhat

Our customer has an email we’ve already created, and their contact id is 19. If you don’t have the contact already created, learn how to do that here. Or can get the id of an already-existing contact by using their email (user@test.com) with a GET call to https://{{yourAccountName}}.api-us1.com/api/{{apiVersion}}/contacts?filters[email]=user@test.com)

We send that order information with a POST using the schema id (it won’t change) to https://{{yourAccountName}}.api-us1.com/api/3/customObjects/records/{{schema id goes here}}

Using the schema id, the complete url is: https://{{yourAccountName}}.api-us1.com/api/3/customObjects/records/968535b7-9b8f-4398-af54-37611defcf89

{ 
    "record": {
        "fields": [ 
        {
            "id": "order-price",
            "value": 14.00
        },
        {
            "id": "order-number",
            "value": 3552
        },
        {
            "id": "order-count",
            "value": 2
        },
        {
            "id": "product-name",
            "value": "Green Hat"
        },
        {
            "id": "product-link",
            "value": "https://www.example.com/greenhat"
        }
        ],
        "relationships": {
            "primary-contact": [ 19 ]
        }
    }
}

You will then see on that contact, the complete record of their order, and the product link:

Shared with CloudApp

3. To send an email to that contact with the information you saved in a Custom Object, you need to:

Create an automation:

Create an automation by clicking “automations” and “Create and Automation”:

Shared with CloudApp

Click “Add a start trigger”

Shared with CloudApp

Click “Objects” then the name of your custom object (our is “Website Orders”) then “Website Order is created”

Shared with CloudApp

You can then do whatever you would like inside the automation:

Shared with CloudApp

If you navigate in ActiveCampaign to SETTINGS → MANAGE DATA you will see your custom object schema:

Shared with CloudApp

Inside, you will find the personalization tags you need to add to each email to reference data inside the custom object:

Shared with CloudApp

Reference the custom object data inside the email using each item’s tag:

Shared with CloudApp

Your email will look like this:

Shared with CloudApp

1 Like