Use Confection Event Values to Create Custom JSON Objects and Arrays

As we outline in this post and this post, Confection custom events can help users capture platform identifiers and prepare data for Facebook/Meta's Conversions API (CAPI) and Google Ads API. But these are just three specific applications of a more agnostic feature. You can use JSON-encoded Confection custom event values to create your own event-based custom objects and arrays. Organize data so it's convenient for you and customized for target endpoints.

Read More

Subscribe

We'll send updates directly to your email inbox.

  • Hidden
 

Learn more about marketing disruptions involving cookies, cross-domain scripts, and device IDs. Get tips for using your Confection account effectively. Read customer experiences.

Short and powerful: confection.submitEvent("eventName", JSON.stringify({%Your Object/Array Here%}));

Confection custom event values support any JSON-encoded string. Use this feature to create your own event-based custom objects and arrays. Organize data so it's convenient for you and customized for target endpoints.

Continue Reading

Subscribe

Educating yourself about privacy first disruptions and opportunities? Keeping an eye on the future of cookies, cross-domain scripts, and device IDs? We can help. Subscribe, and we’ll send content like this directly to your email inbox.

  • Hidden

About Confection Events

Confection automatically tracks the following kinds of events:

  • form fields (which we treat as PII)
  • page load speed
  • pageviews and associated session intel (eg., acquisition data)

With a few lines of code, customers can also track eCommerce purchase events and send them directly to GA and Matomo. See this documentation for more information.

As we outline in our dashboard documentation, Confection also supports generic custom events. To submit a custom Confection event, use this syntax:

Add that above your site’s </head> tag and below your Confection header code. For example, if you wanted to submit a custom event named click with a value of 1, you’d add this to your site:

<script>
confection.submitEvent("click", 1);
</script>

Create Your Own Custom Objects and Arrays

In addition to integers and text strings, Confection custom event values also support JSON-encoded strings. Customers can use this feature to capture platform identifiers and to write Confection data to the CAPI and the Google Ads API. But these are just three specific applications of an agnostic feature. You can create any custom objects and arrays that are helpful to you.

Two examples follow.

Example 1: Open Form (Freestyle)

URL parameters are incredible front-end workhorses. They can can help identify users. They can help sort, filter, or paginate content. They can pass search queries and serve product details or translated text. They can help track site activity and log campaign information.

Let's imagine you're using URL parameters to do several of these and that you want to associate relevant parameter values with Confection UUIDs.

Here's a URL with sample parameters:

http://www.example.com/page/?id=user-123&product=shirts&size=medium&language=en&campaign=paid-search

To log these parameters and organize them into a custom object, you could just add code like this below your Confection footer JS and above your site's closing </body> tag:

Using the URL and sample parameters above, this will output to your Confection account as a custom event structured as follows:

From there, you can organize the data for input wherever you like: CRM, ad campaign, custom audience, analytics dashboard, &c.

Example 2: Closed Form (Endpoint Specific)

Let's imagine you want to structure event data so it meets the schema requirements of a particular platform. Our CAPI and Google Ads API are examples of this in action. One other follows.

We know HubSpot's core analytics script is is frequently blocked. The script name varies by account number, but ours is https://js.hs-analytics.net/analytics/1692897900000/7349006.js. When this script fails to fire, HubSpot users experience severe consequences:

  • HubSpot can't collect and record user interactions, such as pageviews, clicks, form submissions, and other engagement events. This will lead to incomplete or inaccurate data in analytics reports.
  • The failure to track user interactions and incomplete analytics data will make it difficult to analyze user behavior, identify trends, and make informed decisions.
  • Conversion events such as sign-ups, downloads, or purchases won't be captured. As a result, a HubSpot user won't have an accurate portrait of their website's ability to convert visitors.
  • HubSpot users will miss insights into user behavior, preferences, and engagement patterns, which could hinder their ability to optimize website content and UX.
  • If a HubSpot user is tracking data to personalize content for visitors, the lack of data could lead to subpar personalization experiences.
  • If a HubSpot user is running marketing campaigns and relying on accurate tracking data to measure their performance, the failure of tracking could hinder that user's ability to assess campaign effectiveness.
  • Any reports generated using incomplete or inaccurate data would be unreliable and might not reflect the true state of a website's performance.
  • If a HubSpot user is collecting user data and tracking interactions, this script's failure could potentially lead to privacy concerns or compliance issues. HubSpot's banner.js (eg., https://js.hs-banner.com/v2/7349006/banner.js) also routinely fails to fire, which increases and compounds this particular risk.

You can use a Confection custom event to ensure this data fires properly, and you can use a custom JSON object to easily prepare the payload for ingestion into the HubSpot API. As a simple example, let's assume we want to write pageview events and associated campaign data to HubSpot contact records. You could just add code like this below your Confection footer JS and above your site's closing </body> tag:

This will use HubSpot first-party cookie data to identify the relevant user and pass the pageview and campaign details to your Confection account as a custom event structured as follows:

Note, this matches the data schema HubSpot API expects.

Today is your data independence day.

Take control of your pageviews, acquisition intel, and other "atomic-level" digital marketing data. Get +52-125% better analytics data, +20-30% more effective paid ads, and +88% larger audiences.

Get Started

Live Dataflow
Learn More

Next Steps

Confection collects, stores, and distributes data in a way that's unaffected by client-side disruptions involving cookies, cross-domain scripts, and device IDs. It's also compliant with global privacy laws so it’s good for people too.

See Confection in Action (Risk Free)

Get Started (Risk Free)

"I want to see a demo."

Let’s Go

"How does privacy first affect me?"

Find Out

"I have some questions."

Contact Us

"I want to see this."

Share It

"How much does this cost?"

View Pricing Guide

Discussion

Questions or comments? Leave them below.

Today is your data independence day.

Get started. Risk free.