<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Steve Webb on Medium]]></title>
        <description><![CDATA[Stories by Steve Webb on Medium]]></description>
        <link>https://medium.com/@dotsteve_51901?source=rss-e9fdf415d908------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xhgEloeI6Su8Vjl4JCbsMQ.jpeg</url>
            <title>Stories by Steve Webb on Medium</title>
            <link>https://medium.com/@dotsteve_51901?source=rss-e9fdf415d908------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 05:04:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dotsteve_51901/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Everything I know about Schema Design in Adobe Experience Platform]]></title>
            <link>https://medium.com/station10/everything-i-know-about-schema-design-in-adobe-experience-platform-d5c5bc638b53?source=rss-e9fdf415d908------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5c5bc638b53</guid>
            <category><![CDATA[adobe-cja]]></category>
            <category><![CDATA[digital-analytics]]></category>
            <category><![CDATA[adobe-experience-platform]]></category>
            <dc:creator><![CDATA[Steve Webb]]></dc:creator>
            <pubDate>Thu, 04 Sep 2025 15:42:34 GMT</pubDate>
            <atom:updated>2025-09-06T18:02:27.155Z</atom:updated>
            <content:encoded><![CDATA[<h3>Best practises for Schema design in Adobe Experience Platform</h3><p>Schemas are a key component of Adobe Experience Platform (AEP), and it’s very important to get them right early on in the process. Making changes to Schema designs after you’ve started collecting data in a live environment can be quite tricky, if not impossible.</p><p>Adobe offers <a href="https://experienceleague.adobe.com/en/docs/experience-platform/xdm/schema/composition">a lot of information</a> and resources on schema design, but I found a many things a bit unintuitive during my first go at it on a complex project. So here’s everything I’ve learned so far 🙂</p><h3>Before you get started</h3><p>You should not embark on Schema design without first having a really detailed and clear understanding of:</p><ul><li>Your use cases for the AEP tools downstream of the Schemas (i.e. CJA, CDP, AJO)</li><li>What your data sources are</li><li>What is in your data sources</li></ul><p>If you try to jump into Schema design without these things, you’ll likely end up in a mess!</p><h3>Key concepts</h3><h4>Types of data</h4><p>AEP broadly supports two types of data:</p><p><strong>Record data.</strong> This is data about a subject, where each row contains data about one subject.</p><ul><li>Most commonly this is a <strong>customer</strong> record, so each row would contain information about an individual customer.</li><li>But it could also be something else, like a product SKU or a marketing campaign ID. Like a lookup table or a classification set, if you’re familiar with Adobe Analytics.</li></ul><p><strong>Timeseries data</strong>. This is data about actions performed over time by a record subject, usually a customer. Examples would be your website events from Web SDK, call centre events, etc.</p><p><strong>Note: AEP is not a relational database.</strong> The ‘lookup’ behaviour of record datasets does not work with multiple levels. You should avoid defining multiple level relationships, instead ‘lookups’ should only be used in relation to a customer record or timeseries data.</p><h3>Schema paths</h3><p>This might seem obvious, but it’s not really called out explicitly in Adobe’s documentation: <strong>One of the main objectives when designing Schemas is to ensure that the same ‘thing’ always appears in the same Schema path no matter what data source it’s in.</strong></p><p>You’ve likely got ‘customer first name’ in various data sources; e.g. your CRM data, call centre data, website data, etc. These probably live in different Datasets with different Schemas. You want to ensure that wherever this is, it’s <em>always</em>located in the same path: e.g. person.name.firstName, to use an example from Adobe’s standard Field Groups (more on <a href="https://station10.atlassian.net/wiki/spaces/AE/blog/edit-v2/1777598486#Field-Groups">Field Groups</a> later).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2SYJ2LK2xxIdR4rN-OZC5w.png" /><figcaption>Person name field group</figcaption></figure><p>Why is this necessary? AEP performs unions between datasets in various places in the platform. For example;</p><ul><li>In Customer Journey Analytics (CJA), events from different timeseries Datasets are unioned together. So, if your ‘customer first name’ is always in the same Schema path, the customer names in different datasets will appear as a single Dimension in CJA. If they’re in different paths, you’ll get multiple dimensions for the same thing.</li><li>In Customer Data Platform, record Datasets about profiles (usually customers) are unioned together. So again, you want to ensure that ‘customer first name’ is always in the same Schema path across different profile datasets so there there is only one ‘customer first name’ field in the <a href="https://experienceleague.adobe.com/en/docs/platform-learn/tutorials/profiles/union-schemas-overview">unioned schema</a>.</li></ul><p>To illustrate this we can steal a couple of diagrams from <a href="https://experienceleague.adobe.com/en/docs/experience-platform/xdm/schema/composition#union">Adobe’s documentation</a>.</p><p>Say we’ve got two Profile-class Schemas, one from our Customer database and one from our Loyalty Members database. They both contain First Name and Last Name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I4PPGJ44voq3Us0lk_eizQ.png" /><figcaption>Individual Profile Schemas</figcaption></figure><p>Assuming you’ve done your Schema design correctly and these fields share the same paths, if these two Schemas are enabled for Profile, then Union Schema in Profile will look like this, with First Name and Last Name merged into a single Schema:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mXBY7n0s3ZDd9X-uW18C2A.png" /><figcaption>The Union Schema merges the underlying Schemas</figcaption></figure><p>This doesn’t just apply to Profile, it applies to any Schemas that share the same Class and are enabled for Profile (more on Classes below).</p><h3>Schema changes</h3><p>One last thing to explain before going further: You want to get the Schema design correct up front before you start doing anything serious in production, because:</p><ul><li>Once a Schema has data in it, you cannot remove fields from it, you can only add new fields. (Technically you can <a href="https://experienceleague.adobe.com/en/docs/experience-platform/xdm/tutorials/field-deprecation-ui">deprecate a field</a>, but at the time of writing this isn’t well supported in the UI in all scenarios)</li><li>You can delete the Dataset(s) associated with a Schema and then make edits to it, but that’s only helpful if you can easily reload the data again once you’re done. This is feasible if you’re loading data from another system where it’ll still exist, but for something like a web dataset where events are being collected via AEP Web SDK, this isn’t really possible.</li><li>Once a Schema/Dataset is enabled for Profile, the fields in that can’t be edited, because they form part of the <a href="https://experienceleague.adobe.com/en/docs/experience-platform/profile/union-schemas/union-schema">Union Schema</a> that represents all your Profile information.</li></ul><p>For all these reasons and more, it’s crucial you really nail down your use cases before you embark on an AEP implementation. Or you might find yourself stuck with a sub-optimal data structure that you can’t do anything about.</p><p>With that all out of the way, let’s dive into the details!</p><h3>Schema Building Blocks</h3><h3>Classes</h3><p>Earlier I mentioned that AEP supports two types of data, records and timeseries. The next level below this is a Class.</p><p>A Schema is always assigned a single Class.</p><p>The two most common Classes you’ll use are:</p><p><strong>Experience Event</strong>. This is timeseries data, where a <em>customer</em> is doing something. So your website events data will be Experience Event data, as that data is about customers doing things on your website. This data will need to have two things in it, at minimum:</p><ul><li>Some sort of customer ID or IDs. In the web data example, probably ECID for unauthenticated users and a first-party ID for logged in users</li><li>A timestamp.</li></ul><p><strong>Individual Profile</strong>. This is record data about your customers. So each row will be a customer and at minimum they’ll each have a unique ID.</p><p>But there are plenty of <strong>other Classes</strong>, and you can create your own. Some examples of things you might use a different Class for would be the ‘lookup’ type datasets that we mentioned earlier, like a ‘Product Class’ for info about products your company sells, an ‘Insurance Plan Class’, etc. Or some function-specific classes like the Summary Metrics Class if you want to import <a href="https://experienceleague.adobe.com/en/docs/analytics-platform/using/cja-dataviews/summary-data">Summary data</a> into CJA (i.e. timeseries data that <em>isn’t </em>linked to a customer, like advertising campaigns clicks or performance targets).</p><h3>Field Groups</h3><p>The next Schema component is the Field Group. This is the main component that’s going to help us ensure path consistency across different Schemas. It’s a reusable component that contains some fields and can be used across multiple Schemas of the same Class.</p><p>For example, we might have some customer information in multiple data sources and, like we said before, we want to ensure that the same info is in the same Schema paths every time. So we could create a Field Group for that customer info, which we then use across multiple Schemas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zfjzzz8St9qbobCpB3fLQw.png" /><figcaption>Demgraphic Details field group</figcaption></figure><p>You can create your own Field Groups from within the Schema UI, but first you should check to see if there are any default Adobe ones that fit your use case. Adobe have a huge number of pre-configured ones, and it’s beneficial to use them where possible for a few reasons:</p><ul><li>It’ll save you time not having to create them from scratch.</li><li>Some AEP functionality assumes you’ve used the default ones, for example the ‘Profiles &gt; Browse’ page assumes you’ve used the default <a href="https://experienceleague.adobe.com/en/docs/experience-platform/xdm/field-groups/profile/demographic-details">Demographic Details</a> Field Group. You also must use the <a href="https://experienceleague.adobe.com/en/docs/experience-platform/xdm/field-groups/profile/consents">Consents and Preferences</a> Field Group to use the consent features of CDP.</li><li>Adobe have indicated it’s likely they’ll be building more functionality on top of the default Field Groups in the future. I’d assume particularly AI stuff where consistency across their clients would be useful.</li></ul><p>One thing you might be thinking is that the Adobe-provided Field Groups are <em>massive </em>and full of junk you don’t need (who needs <a href="https://experienceleague.adobe.com/en/docs/experience-platform/xdm/field-groups/profile/personal-contact-details">fax phone numbers</a> in 2025?).</p><p>Well, you can choose which of a Field Group’s fields you use in a particular Schema, using these two options in the Schema UI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tD1vu00u5CtsEPDwrTg0ig.png" /><figcaption>Add/remove fields from a Field Group</figcaption></figure><p>This means you can pick only the fields that are relevant to your Dataset, while being sure that whatever fields you do pick, they’ll align with other Schemas that are using the same Field Group. (And you definitely do want to remove any unused fields, so that your Schema and downstream tools aren’t cluttered with empty fields)</p><h3>Data Types</h3><p>There is a level below Field Groups and these are called Data Types.</p><p>This was a source of some confusion to me, because Data Types sort of cover two sorts of functionality. You select the Data Type from a dropdown in the Schema UI that’s located at the level of a particular field.</p><p>In here you see ‘basic’ Data Types, which are things you might expect to describe what sort of data goes into a field (strings, dates, integers, booleans, etc):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B_oNWCXNNBt8jiFYGHeiQw.png" /><figcaption>Basic Data Types</figcaption></figure><p>But Data Types can <em>also </em>be groups of fields (and those fields themselves will have Data Types…)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EaTLF3GYckbhCOAvAN1otA.png" /><figcaption>Data Types as groups of other fields</figcaption></figure><p>This is pretty confusing, why not just use a Field Group for this? Well there are some important differences in how Field Groups and Data Types function:</p><h3>Field Groups vs Data Types</h3><p>When should you use Field Groups and when should you use Data Types?</p><h4>Position</h4><ul><li><strong>Field Groups</strong> always go at the root of the Schema.</li><li><strong>Data Types</strong> can be used in any position in the Schema.</li></ul><h4>Repeatability</h4><ul><li><strong>Field Groups </strong>can only be used once in each Schema</li><li><strong>Data Types </strong>can be used multiple times in the same Schema</li></ul><h4>What they can contain</h4><ul><li><strong>Field Groups</strong> can contain Data Types, but not other Field Groups</li><li><strong>Data Types</strong> can contain other Data Types</li></ul><h4>Class Compatibility</h4><ul><li><strong>Field Groups</strong> are not necessarily compatible with all Classes</li><li><strong>Data Types</strong> can be used in any Class</li></ul><p>Ok, that makes some sense, but let’s illustrate this with the example of Adobe’s Demographic Details Field Group:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*pF74tGUWuXAGgYjrnuhHHg.png" /><figcaption>Adobe’s ‘Demographic Details’ Field Group includes the ‘Person name’ Data Type</figcaption></figure><ul><li>It’s highly likely that your Schema only ever has one ‘customer’ per row at a time, so you don’t need to have these ‘person’ demographic details more than once in the same Schema. So a <strong>Field Group</strong> works for this.</li><li>However it’s possible that a ‘person name’ could be used more than once in the same Schema. Maybe your customer has an assigned support person, and you want to record their name too. Here’s where using a <strong>Data Type</strong> (as Adobe have done) makes sense because you might want to use ‘person name’ elsewhere in the same Schema.</li></ul><h3>Fields</h3><p>Lastly, below Data Types we have Fields. These are basic things that define a single field, like a string or an integer, and will represent the actual columns in your datasets.</p><p>There’s a bunch of configuration available on these such as defining string length, regex matches, enforced enums, etc. I won’t go into these in detail as the <a href="https://experienceleague.adobe.com/en/docs/experience-platform/xdm/ui/fields/overview#type-specific-properties">Adobe documentation</a> has that covered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*O9ESiYyldXUcByAh6MgqOg.png" /><figcaption>Field validation options</figcaption></figure><p><strong>Note that you should be careful with these validation fields</strong>: They’re useful for ensuring incorrect data doesn’t get into your datasets, but be aware that any field that fails data validation will cause the <em>entire row</em> to be dropped. This may or may not be what you want to happen.</p><p>Say, you accidentally publish a change to your web tracking that causes a string to be an integer in a single dimension? Every event that affects will be lost 😬</p><h3>Nested vs Flat Schema Structures</h3><p>Another decision to make is how to structure your Schemas in terms of how nested or not they are. This is a somewhat aesthetic choice, but there are some pros and cons to be aware of:</p><h4>Benefits of nested fields (objects)</h4><ul><li>Lets you organise your data into logical groups, rather than just a giant list in alphabetical order.</li><li>Makes your Schemas more readable and easier to navigate.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wCBins4DKwlrgpqz0r5wmA.png" /><figcaption>Some nested fields to keep all your URL query strings neatly organised</figcaption></figure><h4>Benefits of non-nested fields (free-form)</h4><ul><li>Results in shorter Schema paths, which can make working with Query Service and some parts of the UI easier.</li><li>Has benefits to performance, specifically for IDs where Adobe recommend that <a href="https://experienceleague.adobe.com/en/docs/experience-platform/profile/guardrails#:~:text=The%20recommended%20maximum%20JSON%20depth%20for%20an%20ID%20field%20used%20in%20multi%2Dentity%20relationships%20is%204.%20This%20means%20that%20in%20a%20highly%20nested%20schema%2C%20fields%20that%20are%20nested%20more%20than%204%20levels%20deep%20should%20not%20be%20used%20as%20an%20ID%20field%20in%20a%20relationship.">IDs used in relationships are no more than 4 levels deep</a> as a performance guardrail.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AVp8cr8r5cK2PNbOgHWOLA.png" /><figcaption>Long Schema path names can be annoying in Query Service</figcaption></figure><h3>Identities</h3><p>Identities are a core part of AEP; they are the things you’ll be using to stitch your data together. Most often these are customer identifiers, things like a cookie ID, an email address, or a phone number.</p><p>But confusingly, ‘Identities’ also include the keys that are used to join non-customer data together: So, in the example where we have a Product SKU in an events dataset and then a lookup dataset of Product info, the Product SKU in this scenario would also be an Identity (just a ‘non-person identity’).</p><p>Identities are a whole blog-post in themselves, but in terms of Schema design there are a few key things to remember:</p><ul><li>Field in your Schemas marked as ‘person identities’ are inserted into the Identity Graph, and that is used to provide a single stitched together view of an individual customer.</li><li>Identities can be set in either normal Schema fields or the identityMap</li><li>For Schemas where you have a consistent identity on all rows (e.g. a Customer ID in your CRM Dataset) you can just use a specific field in the Schema.</li><li>Identities used in <a href="https://experienceleague.adobe.com/en/docs/experience-platform/xdm/tutorials/relationship-ui">relationships</a> need to be Schema fields and <em>not</em> in the identityMap.</li><li>The identityMap is primarily used in scenarios where you have a shifting ‘primary identity’. A common example is a website dataset, where you want to use the ECID as the Primary Identity on rows where the user <em>is not</em> logged in, but you have a first-party ID that you want to use as the Primary Identity on rows where the user <em>is</em>logged in. <strong>The </strong><strong>identityMap lets you define which ID is the primary Identity on a row-by-row basis, rather than at the level of the Schema.</strong></li><li>As mentioned above, avoid heavily nesting your identity fields for performance reasons.</li></ul><p>Identity fields are super important to the functionality of the rest of AEP, so a good idea is to have a specific Field Group which contains all your companies’ identities. This will make them easier to manage, rather than having them spread all over your Schemas in different places.</p><h3>Style guide</h3><p>This is basically what Adobe use in their default Field Groups, but I thought it useful to articulate the principles here:</p><ul><li><strong>Field Names should be camel-case</strong>, e.g. dateOfBirth. (Note that ID fields or similar should be userID and not userId)</li><li><strong>Display Name should be human readable (title-case)</strong>, e.g. Date Of Birth.</li><li><strong>Dimensions should be singular</strong>, e.g. formFieldName, videoName, pageName, applicationID, etc.</li><li><strong>Metrics should be plural</strong>, e.g. formFieldCompletes, videoStarts, pageViews, etc.</li></ul><p>Though it’s bit verbose, we should follow Adobe’s lead when creating fields in our Schemas that are to be used as metrics:</p><ul><li>Metric fields are Objects</li><li>Inside the Object is an int field called value. Usually this value will be populated with a 1, to count that this thing happened. This also supports the equivalent of Adobe Analytics ‘numeric’ events, where you might want to track a number other than 1. For example, you might have a coreWebVitals.lcpScore.value of 2000.</li><li>Optionally, you can include a field called id. This is to support easy <a href="https://experienceleague.adobe.com/en/docs/analytics-platform/using/cja-dataviews/component-settings/metric-deduplication">metric deduplication</a>, where you might want to track an event only once per a unique ID. For example, only tracking a ‘purchase’ metric once per unique ‘purchase id’.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8SFIWHb7acTCqknN_1RnLQ.png" /><figcaption>Metrics in a Schema</figcaption></figure><h3>Wrapping up</h3><p>And there we go! Hopefully that was useful to someone, would love to hear other people’s thoughts or opinions.</p><p>And as always, if you’re looking for a partner to support you anything AEP-related, do reach out to us on <a href="/service/mailto:hello@station10.co.uk">hello@station10.co.uk</a> 🙂</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5c5bc638b53" width="1" height="1" alt=""><hr><p><a href="https://medium.com/station10/everything-i-know-about-schema-design-in-adobe-experience-platform-d5c5bc638b53">Everything I know about Schema Design in Adobe Experience Platform</a> was originally published in <a href="https://medium.com/station10">Station10</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tracking Core Web Vitals in Adobe Analytics]]></title>
            <link>https://medium.com/station10/tracking-core-web-vitals-in-adobe-analytics-538e03a9ea17?source=rss-e9fdf415d908------2</link>
            <guid isPermaLink="false">https://medium.com/p/538e03a9ea17</guid>
            <category><![CDATA[core-web-vitals]]></category>
            <category><![CDATA[adobe-launch]]></category>
            <category><![CDATA[adobe-analytics]]></category>
            <category><![CDATA[adobe-experience-platform]]></category>
            <dc:creator><![CDATA[Steve Webb]]></dc:creator>
            <pubDate>Thu, 01 Feb 2024 14:56:58 GMT</pubDate>
            <atom:updated>2024-02-01T15:07:36.170Z</atom:updated>
            <content:encoded><![CDATA[<p>Google’s <a href="https://web.dev/articles/vitals#core_web_vitals">core web vitals</a> are the industry standard for measuring a website&#39;s performance and its impact on user experience. They measure things like loading performance, interactivity, and the stability of content as it loads.</p><p>You can see Core Web Vitals for a page using the Lighthouse tab in the Chrome developer console:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*becUmQQgrVOPbjRU9Qi2VQ.png" /></figure><p>This is useful for a one-off snapshot, but what if you want to track these metrics over time? Or break them down by different user segments or any of the other things you might be tracking in Adobe Analytics? This blog will guide you through the steps you can take to measure Core Web Vitals in Adobe Analytics!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*obA8YbES7HiAUbd_cK4OmQ.png" /><figcaption>Web Vitals metrics over time, split by Device Type</figcaption></figure><h3>The web vitals library</h3><p>Happily, Google provides the tools to measure core web vitals in a handy JavaScript library which you can find here: <a href="https://github.com/GoogleChrome/web-vitals">https://github.com/GoogleChrome/web-vitals</a></p><p>This library is a tiny modular library for measuring all the <a href="https://web.dev/articles/vitals">Web Vitals</a> metrics on real users, in a way that accurately matches how they’re measured by Chrome and reported to other Google tools (e.g. <a href="https://developers.google.com/web/tools/chrome-user-experience-report">Chrome User Experience Report</a>, <a href="https://developers.google.com/speed/pagespeed/insights/">Page Speed Insights</a>, <a href="https://webmasters.googleblog.com/2019/11/search-console-speed-report.html">Search Console’s Speed Report</a>).</p><h3>Setting up the tracking in Adobe Launch</h3><h4>Adding the library to Adobe Launch</h4><p>The examples in the GitHub docs either load the library as an NPM package or from a CDN, and I’d recommend using these methods if you can. But, if you have no support from your website developers and want to achieve this 100% in Adobe Launch custom code, the library is small enough to just copy and paste the whole thing into a Launch custom code action.</p><p>So for this example, that’s what we’re doing:</p><ol><li>Create a new rule that executes on ‘Core — Library Loaded (Page Top)’</li><li>Navigate to <a href="https://unpkg.com/web-vitals@3/dist/web-vitals.iife.js">https://unpkg.com/web-vitals@3/dist/web-vitals.iife.js</a> and paste the whole script into a Custom Code action:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NT_GK-9HNIyliEtqAGUq3A.png" /><figcaption>Quick and dirty way to load the Web Vitals library via Adobe Launch</figcaption></figure><h3>Writing our script</h3><p>Now what we’re going to do is take a couple of examples from the GitHub docs that are intended for sending the data to Google Analytics, and mash them together to create our own script for sending the data to Adobe Analytics instead.</p><p>We can start with <a href="https://github.com/GoogleChrome/web-vitals?tab=readme-ov-file#send-the-results-to-google-analytics">this example</a> where we’re simply sending some data to Google Analytics:</p><pre>import {onCLS, onFID, onLCP} from &#39;web-vitals&#39;;<br><br>function sendToGoogleAnalytics({name, delta, value, id}) {<br>  // Assumes the global `gtag()` function exists, see:<br>  // https://developers.google.com/analytics/devguides/collection/ga4<br>  gtag(&#39;event&#39;, name, {<br>    // Built-in params:<br>    value: delta, // Use `delta` so the value can be summed.<br>    // Custom params:<br>    metric_id: id, // Needed to aggregate events.<br>    metric_value: value, // Optional.<br>    metric_delta: delta, // Optional.<br><br>    // OPTIONAL: any additional params or debug info here.<br>    // See: https://web.dev/articles/debug-performance-in-the-field<br>    // metric_rating: &#39;good&#39; | &#39;needs-improvement&#39; | &#39;poor&#39;,<br>    // debug_info: &#39;...&#39;,<br>    // ...<br>  });<br>}<br><br>onCLS(sendToGoogleAnalytics);<br>onFID(sendToGoogleAnalytics);<br>onLCP(sendToGoogleAnalytics);</pre><p>This is a simple script that just sends an event to GA4 on each of the CLS, FID and LCP events, with a few dimensions that come from the web vitals event.</p><p>To repurpose this for Adobe Analytics, we can do the following:</p><h4>Variable Definitions</h4><p>First, let&#39;s set a couple of objects that we can use to define which evars and events we want to put our data in, when we send it to Analytics:</p><pre>// define which evars and events to use<br>var eventMap = {<br>    &#39;CLSvalue&#39;: &#39;event100&#39;,<br>    &#39;FIDvalue&#39;: &#39;event101&#39;,<br>    &#39;LCPvalue&#39;: &#39;event102&#39;,<br>    &#39;FCPvalue&#39;: &#39;event103&#39;,<br>    &#39;TTFBvalue&#39;: &#39;event104&#39;,<br>    &#39;INPvalue&#39;: &#39;event105&#39;,<br>};<br><br>var evarMap = {<br>    &#39;CLSrating&#39;: &#39;eVar110&#39;,<br>    &#39;FIDrating&#39;: &#39;eVar111&#39;,<br>    &#39;LCPrating&#39;: &#39;eVar112&#39;,<br>    &#39;FCPrating&#39;: &#39;eVar116&#39;,<br>    &#39;TTFBrating&#39;: &#39;eVar118&#39;,<br>    &#39;INPrating&#39;: &#39;eVar120&#39;,<br>    &#39;CLSnavigationType&#39;: &#39;eVar113&#39;,<br>    &#39;FIDnavigationType&#39;: &#39;eVar114&#39;,<br>    &#39;LCPnavigationType&#39;: &#39;eVar115&#39;,<br>    &#39;FCPnavigationType&#39;: &#39;eVar117&#39;,<br>    &#39;TTFBnavigationType&#39;: &#39;eVar119&#39;,<br>    &#39;INPnavigationType&#39;: &#39;eVar121&#39;,<br>};</pre><ol><li>eventMap: A mapping of Core Web Vitals metric names to their corresponding Adobe Analytics event number.</li><li>evarMap: A similar mapping, but for Adobe Analytics eVars, where we want to put some of the dimensions that we get back from the web vitals library.</li></ol><h4>Functions</h4><p>Next, we want to create a couple of functions that handle setting the s.events string and the s.eVar values.</p><p><strong>createEventsString(requestBody, eventMap)</strong></p><pre>// function to set s.event string<br>function returnEventsString(requestBody, eventMap) {<br>    var eventString = &#39;&#39;;<br>    for (var i = 0; i &lt; requestBody.length; i++) {<br>        var entry = requestBody[i];<br>        var eventName = eventMap[entry.name + &#39;value&#39;];<br>        if (eventName) {<br>            eventString = (eventString ? eventString + &#39;,&#39; : &#39;&#39;) + eventName + &#39;=&#39; + entry.value;<br>        }<br>    }<br>    _satellite.logger.log(&quot;Core Web Vitals Handler: s.events set to &quot;, eventString);<br>    return eventString;<br>}</pre><ul><li>This function iterates over the requestBody (More on that later, but in short, it&#39;s an array of Core Web Vitals metrics that we get back from the library).</li><li>For each metric, it finds the corresponding event in eventMap and adds it to the eventString.</li></ul><p><strong>returnEvars(requestBody, evarMap):</strong></p><pre>// function to return the evars we want as an object<br>function returnEvars(requestBody, evarMap) {<br>    var evars = {};<br>    for (var i = 0; i &lt; requestBody.length; i++) {<br>        var entry = requestBody[i];<br>        var evarName = evarMap[entry.name + &#39;rating&#39;];<br>        if (evarName) {<br>            evars[evarName] = entry.rating;<br>        }<br>        var evarName = evarMap[entry.name + &#39;navigationType&#39;];<br>        if (evarName) {<br>            evars[evarName] = entry.navigationType;<br>        }<br>    }<br>    return evars;<br>}</pre><ul><li>Similar to createEventsString, but this function constructs an object of eVars instead of a string of events.</li><li>It iterates over requestBody, and for the rating and navigationType dimensions, it sets the corresponding eVar names and values in the returned object.</li></ul><h4>Batching multiple reports together</h4><p>Rather than reporting each individual Web Vitals metric separately, we want to minimize the number of server calls we send to Adobe, so we can follow <a href="https://github.com/GoogleChrome/web-vitals?tab=readme-ov-file#batch-multiple-reports-together">this example in the docs</a> where we batch multiple metric reports together in a single network request.</p><p>This is done by creating a ‘queue’ to which we add the events, and then we send off all the events as the user navigates away from the page.</p><p><strong>addToQueue(metric)</strong></p><pre>const queue = new Set();<br>function addToQueue(metric) {<br>    queue.add(metric);<br>}</pre><ul><li>This adds a metric to the queue, a Set used to store Core Web Vitals metrics before they are sent to Adobe Analytics.</li></ul><p><strong>flushQueue():</strong></p><pre>function flushQueue() {<br>    if (queue.size &gt; 0) {<br>        try {<br>            const requestBody = [...queue];<br><br>            // set the s.events object<br>            s.events = returnEventsString(requestBody, eventMap)<br><br>            // for the events in the event string, set s.linkTrackEvents to a comma separeated list of the events<br>            s.linkTrackEvents = s.events.split(&#39;,&#39;).map(function (event) {<br>                return event.split(&#39;=&#39;)[0];<br>            }).join(&#39;,&#39;);<br><br>            // set the evars<br>            evars = returnEvars(requestBody, evarMap);<br>            for (var evarName in evars) {<br>                if (evars.hasOwnProperty(evarName)) {<br>                    // set evar<br>                    s[evarName] = evars[evarName];<br>                    // add to linkTrackVars<br>                    s.linkTrackVars = s.linkTrackVars ? s.linkTrackVars + &#39;,&#39; + evarName : evarName;<br>                    _satellite.logger.log(&quot;Core Web Vitals Handler: s.&quot; + evarName + &quot; set to&quot;, s[evarName]);<br>                }<br>            }<br><br>            // call function to send data to Adobe<br>            s.tl(true, &#39;o&#39;, &#39;Core Web Vitals&#39;);<br><br>            //console logging<br>            _satellite.logger.log(&quot;Core Web Vitals Handler: requestBody&quot;, requestBody);<br>            _satellite.logger.log(&quot;Core Web Vitals Handler: event sent&quot;);<br><br>            queue.clear();<br>        } catch (err) {<br>            _satellite.logger.log(&quot;Core Web Vitals Handler: error&quot;, err);<br>        }<br>    }<br>}</pre><ul><li>This function is called to send the collected metrics to Adobe Analytics.</li><li>It converts the queue to an array (this is the requestBodythat we referenced earlier) and uses createEventsString and returnEvars functions to set up the s.events and s.eVars objects.</li><li>s.linkTrackEvents and s.linkTrackVars are updated for tracking in Adobe Analytics.</li><li>s.tl() function is called to send the data to Adobe Analytics.</li><li>The function logs the sent data and finally clears the queue.</li></ul><h4>Add Event Listeners</h4><pre>webVitals.onCLS(addToQueue);<br>webVitals.onFID(addToQueue);<br>webVitals.onLCP(addToQueue);<br>webVitals.onFCP(addToQueue);<br>webVitals.onTTFB(addToQueue);<br>webVitals.onINP(addToQueue);</pre><ul><li>Add event listeners for Core Web Vitals so they are added to the queue when they are available.</li></ul><h4>Page Visibility and Unload Handling</h4><pre>// Report all available metrics whenever the page is backgrounded or unloaded.<br>addEventListener(&#39;visibilitychange&#39;, () =&gt; {<br>    if (document.visibilityState === &#39;hidden&#39;) {<br>        flushQueue();<br>    }<br>});<br><br>// NOTE: Safari does not reliably fire the `visibilitychange` event when the<br>// page is being unloaded. If Safari support is needed, you should also flush<br>// the queue in the `pagehide` event.<br>addEventListener(&#39;pagehide&#39;, flushQueue);</pre><ul><li>Then lastly we add an event listener to the visibilitychange event. So that when the page is hidden (i.e. the user navigates away from the page) flushQueue is called to send off all the metrics to Adobe.</li><li>As per Google’s example code, we also add another event listener to better support Safari.</li></ul><h3>Sampling</h3><p>Now, with Adobe Analytics we likely don’t want to increase our server calls too much as that can increase costs. You’ll notice if you start tracking these events, even with the batching method detailed above, that you’ll likely be getting at least a couple of events per page.</p><p>To mitigate this I recommend adding a Sampling condition to your Adobe Launch rule so that it only fires in something like 5% of page loads. In my experience, this is more than enough to get useful metrics, without significantly driving up your server call volumes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*m3FCNYvsJD--pBLsW-NqeQ.png" /><figcaption>A sampling condition on our Launch rule</figcaption></figure><h3>Putting that all together</h3><p>So we should end up with a rule that looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*sdIRoD0RfYqI_HM8iOcYzg.png" /></figure><p>And within the ‘Custom Code’ action, we have the following script:</p><pre>// load the standard core web vitals library<br>// copied from &#39;https://unpkg.com/web-vitals@3/dist/web-vitals.iife.js&#39;;<br>// reference: https://github.com/GoogleChrome/web-vitals<br>var webVitals = function (e) { &quot;use strict&quot;; var n, t, r, i, o, a = -1, c = function (e) { addEventListener(&quot;pageshow&quot;, (function (n) { n.persisted &amp;&amp; (a = n.timeStamp, e(n)) }), !0) }, u = function () { return window.performance &amp;&amp; performance.getEntriesByType &amp;&amp; performance.getEntriesByType(&quot;navigation&quot;)[0] }, f = function () { var e = u(); return e &amp;&amp; e.activationStart || 0 }, s = function (e, n) { var t = u(), r = &quot;navigate&quot;; return a &gt;= 0 ? r = &quot;back-forward-cache&quot; : t &amp;&amp; (r = document.prerendering || f() &gt; 0 ? &quot;prerender&quot; : document.wasDiscarded ? &quot;restore&quot; : t.type.replace(/_/g, &quot;-&quot;)), { name: e, value: void 0 === n ? -1 : n, rating: &quot;good&quot;, delta: 0, entries: [], id: &quot;v3-&quot;.concat(Date.now(), &quot;-&quot;).concat(Math.floor(8999999999999 * Math.random()) + 1e12), navigationType: r } }, d = function (e, n, t) { try { if (PerformanceObserver.supportedEntryTypes.includes(e)) { var r = new PerformanceObserver((function (e) { Promise.resolve().then((function () { n(e.getEntries()) })) })); return r.observe(Object.assign({ type: e, buffered: !0 }, t || {})), r } } catch (e) { } }, l = function (e, n, t, r) { var i, o; return function (a) { n.value &gt;= 0 &amp;&amp; (a || r) &amp;&amp; ((o = n.value - (i || 0)) || void 0 === i) &amp;&amp; (i = n.value, n.delta = o, n.rating = function (e, n) { return e &gt; n[1] ? &quot;poor&quot; : e &gt; n[0] ? &quot;needs-improvement&quot; : &quot;good&quot; }(n.value, t), e(n)) } }, v = function (e) { requestAnimationFrame((function () { return requestAnimationFrame((function () { return e() })) })) }, p = function (e) { var n = function (n) { &quot;pagehide&quot; !== n.type &amp;&amp; &quot;hidden&quot; !== document.visibilityState || e(n) }; addEventListener(&quot;visibilitychange&quot;, n, !0), addEventListener(&quot;pagehide&quot;, n, !0) }, m = function (e) { var n = !1; return function (t) { n || (e(t), n = !0) } }, h = -1, g = function () { return &quot;hidden&quot; !== document.visibilityState || document.prerendering ? 1 / 0 : 0 }, y = function (e) { &quot;hidden&quot; === document.visibilityState &amp;&amp; h &gt; -1 &amp;&amp; (h = &quot;visibilitychange&quot; === e.type ? e.timeStamp : 0, E()) }, T = function () { addEventListener(&quot;visibilitychange&quot;, y, !0), addEventListener(&quot;prerenderingchange&quot;, y, !0) }, E = function () { removeEventListener(&quot;visibilitychange&quot;, y, !0), removeEventListener(&quot;prerenderingchange&quot;, y, !0) }, C = function () { return h &lt; 0 &amp;&amp; (h = g(), T(), c((function () { setTimeout((function () { h = g(), T() }), 0) }))), { get firstHiddenTime() { return h } } }, L = function (e) { document.prerendering ? addEventListener(&quot;prerenderingchange&quot;, (function () { return e() }), !0) : e() }, b = function (e, n) { n = n || {}, L((function () { var t, r = [1800, 3e3], i = C(), o = s(&quot;FCP&quot;), a = d(&quot;paint&quot;, (function (e) { e.forEach((function (e) { &quot;first-contentful-paint&quot; === e.name &amp;&amp; (a.disconnect(), e.startTime &lt; i.firstHiddenTime &amp;&amp; (o.value = Math.max(e.startTime - f(), 0), o.entries.push(e), t(!0))) })) })); a &amp;&amp; (t = l(e, o, r, n.reportAllChanges), c((function (i) { o = s(&quot;FCP&quot;), t = l(e, o, r, n.reportAllChanges), v((function () { o.value = performance.now() - i.timeStamp, t(!0) })) }))) })) }, w = function (e, n) { n = n || {}, b(m((function () { var t, r = [.1, .25], i = s(&quot;CLS&quot;, 0), o = 0, a = [], u = function (e) { e.forEach((function (e) { if (!e.hadRecentInput) { var n = a[0], t = a[a.length - 1]; o &amp;&amp; e.startTime - t.startTime &lt; 1e3 &amp;&amp; e.startTime - n.startTime &lt; 5e3 ? (o += e.value, a.push(e)) : (o = e.value, a = [e]) } })), o &gt; i.value &amp;&amp; (i.value = o, i.entries = a, t()) }, f = d(&quot;layout-shift&quot;, u); f &amp;&amp; (t = l(e, i, r, n.reportAllChanges), p((function () { u(f.takeRecords()), t(!0) })), c((function () { o = 0, i = s(&quot;CLS&quot;, 0), t = l(e, i, r, n.reportAllChanges), v((function () { return t() })) })), setTimeout(t, 0)) }))) }, S = { passive: !0, capture: !0 }, P = new Date, I = function (e, i) { n || (n = i, t = e, r = new Date, M(removeEventListener), A()) }, A = function () { if (t &gt;= 0 &amp;&amp; t &lt; r - P) { var e = { entryType: &quot;first-input&quot;, name: n.type, target: n.target, cancelable: n.cancelable, startTime: n.timeStamp, processingStart: n.timeStamp + t }; i.forEach((function (n) { n(e) })), i = [] } }, F = function (e) { if (e.cancelable) { var n = (e.timeStamp &gt; 1e12 ? new Date : performance.now()) - e.timeStamp; &quot;pointerdown&quot; == e.type ? function (e, n) { var t = function () { I(e, n), i() }, r = function () { i() }, i = function () { removeEventListener(&quot;pointerup&quot;, t, S), removeEventListener(&quot;pointercancel&quot;, r, S) }; addEventListener(&quot;pointerup&quot;, t, S), addEventListener(&quot;pointercancel&quot;, r, S) }(n, e) : I(n, e) } }, M = function (e) { [&quot;mousedown&quot;, &quot;keydown&quot;, &quot;touchstart&quot;, &quot;pointerdown&quot;].forEach((function (n) { return e(n, F, S) })) }, D = function (e, r) { r = r || {}, L((function () { var o, a = [100, 300], u = C(), f = s(&quot;FID&quot;), v = function (e) { e.startTime &lt; u.firstHiddenTime &amp;&amp; (f.value = e.processingStart - e.startTime, f.entries.push(e), o(!0)) }, h = function (e) { e.forEach(v) }, g = d(&quot;first-input&quot;, h); o = l(e, f, a, r.reportAllChanges), g &amp;&amp; p(m((function () { h(g.takeRecords()), g.disconnect() }))), g &amp;&amp; c((function () { var c; f = s(&quot;FID&quot;), o = l(e, f, a, r.reportAllChanges), i = [], t = -1, n = null, M(addEventListener), c = v, i.push(c), A() })) })) }, k = 0, B = 1 / 0, x = 0, R = function (e) { e.forEach((function (e) { e.interactionId &amp;&amp; (B = Math.min(B, e.interactionId), x = Math.max(x, e.interactionId), k = x ? (x - B) / 7 + 1 : 0) })) }, H = function () { return o ? k : performance.interactionCount || 0 }, N = function () { &quot;interactionCount&quot; in performance || o || (o = d(&quot;event&quot;, R, { type: &quot;event&quot;, buffered: !0, durationThreshold: 0 })) }, O = 0, _ = function () { return H() - O }, j = [], q = {}, V = function (e) { var n = j[j.length - 1], t = q[e.interactionId]; if (t || j.length &lt; 10 || e.duration &gt; n.latency) { if (t) t.entries.push(e), t.latency = Math.max(t.latency, e.duration); else { var r = { id: e.interactionId, latency: e.duration, entries: [e] }; q[r.id] = r, j.push(r) } j.sort((function (e, n) { return n.latency - e.latency })), j.splice(10).forEach((function (e) { delete q[e.id] })) } }, z = function (e, n) { n = n || {}, L((function () { var t = [200, 500]; N(); var r, i = s(&quot;INP&quot;), o = function (e) { e.forEach((function (e) { (e.interactionId &amp;&amp; V(e), &quot;first-input&quot; === e.entryType) &amp;&amp; (!j.some((function (n) { return n.entries.some((function (n) { return e.duration === n.duration &amp;&amp; e.startTime === n.startTime })) })) &amp;&amp; V(e)) })); var n, t = (n = Math.min(j.length - 1, Math.floor(_() / 50)), j[n]); t &amp;&amp; t.latency !== i.value &amp;&amp; (i.value = t.latency, i.entries = t.entries, r()) }, a = d(&quot;event&quot;, o, { durationThreshold: n.durationThreshold || 40 }); r = l(e, i, t, n.reportAllChanges), a &amp;&amp; (a.observe({ type: &quot;first-input&quot;, buffered: !0 }), p((function () { o(a.takeRecords()), i.value &lt; 0 &amp;&amp; _() &gt; 0 &amp;&amp; (i.value = 0, i.entries = []), r(!0) })), c((function () { j = [], O = H(), i = s(&quot;INP&quot;), r = l(e, i, t, n.reportAllChanges) }))) })) }, G = {}, J = function (e, n) { n = n || {}, L((function () { var t, r = [2500, 4e3], i = C(), o = s(&quot;LCP&quot;), a = function (e) { var n = e[e.length - 1]; if (n) { var r = Math.max(n.startTime - f(), 0); r &lt; i.firstHiddenTime &amp;&amp; (o.value = r, o.entries = [n], t()) } }, u = d(&quot;largest-contentful-paint&quot;, a); if (u) { t = l(e, o, r, n.reportAllChanges); var h = m((function () { G[o.id] || (a(u.takeRecords()), u.disconnect(), G[o.id] = !0, t(!0)) }));[&quot;keydown&quot;, &quot;click&quot;].forEach((function (e) { addEventListener(e, h, !0) })), p(h), c((function (i) { o = s(&quot;LCP&quot;), t = l(e, o, r, n.reportAllChanges), v((function () { o.value = performance.now() - i.timeStamp, G[o.id] = !0, t(!0) })) })) } })) }, K = function e(n) { document.prerendering ? L((function () { return e(n) })) : &quot;complete&quot; !== document.readyState ? addEventListener(&quot;load&quot;, (function () { return e(n) }), !0) : setTimeout(n, 0) }, Q = function (e, n) { n = n || {}; var t = [800, 1800], r = s(&quot;TTFB&quot;), i = l(e, r, t, n.reportAllChanges); K((function () { var o = u(); if (o) { var a = o.responseStart; if (a &lt;= 0 || a &gt; performance.now()) return; r.value = Math.max(a - f(), 0), r.entries = [o], i(!0), c((function () { r = s(&quot;TTFB&quot;, 0), (i = l(e, r, t, n.reportAllChanges))(!0) })) } })) }; return e.getCLS = w, e.getFCP = b, e.getFID = D, e.getINP = z, e.getLCP = J, e.getTTFB = Q, e.onCLS = w, e.onFCP = b, e.onFID = D, e.onINP = z, e.onLCP = J, e.onTTFB = Q, Object.defineProperty(e, &quot;__esModule&quot;, { value: !0 }), e }({});<br><br>// define which evars and events to use<br>var eventMap = {<br>    &#39;CLSvalue&#39;: &#39;event100&#39;,<br>    &#39;FIDvalue&#39;: &#39;event101&#39;,<br>    &#39;LCPvalue&#39;: &#39;event102&#39;,<br>    &#39;FCPvalue&#39;: &#39;event103&#39;,<br>    &#39;TTFBvalue&#39;: &#39;event104&#39;,<br>    &#39;INPvalue&#39;: &#39;event105&#39;,<br>};<br><br>var evarMap = {<br>    &#39;CLSrating&#39;: &#39;eVar110&#39;,<br>    &#39;FIDrating&#39;: &#39;eVar111&#39;,<br>    &#39;LCPrating&#39;: &#39;eVar112&#39;,<br>    &#39;FCPrating&#39;: &#39;eVar116&#39;,<br>    &#39;TTFBrating&#39;: &#39;eVar118&#39;,<br>    &#39;INPrating&#39;: &#39;eVar120&#39;,<br>    &#39;CLSnavigationType&#39;: &#39;eVar113&#39;,<br>    &#39;FIDnavigationType&#39;: &#39;eVar114&#39;,<br>    &#39;LCPnavigationType&#39;: &#39;eVar115&#39;,<br>    &#39;FCPnavigationType&#39;: &#39;eVar117&#39;,<br>    &#39;TTFBnavigationType&#39;: &#39;eVar119&#39;,<br>    &#39;INPnavigationType&#39;: &#39;eVar121&#39;,<br>};<br><br>// function to set s.event string<br>function returnEventsString(requestBody, eventMap) {<br>    var eventString = &#39;&#39;;<br>    for (var i = 0; i &lt; requestBody.length; i++) {<br>        var entry = requestBody[i];<br>        var eventName = eventMap[entry.name + &#39;value&#39;];<br>        if (eventName) {<br>            eventString = (eventString ? eventString + &#39;,&#39; : &#39;&#39;) + eventName + &#39;=&#39; + entry.value;<br>        }<br>    }<br>    _satellite.logger.log(&quot;Core Web Vitals Handler: s.events set to &quot;, eventString);<br>    return eventString;<br>}<br><br>// function to return the evars we want as an object<br>function returnEvars(requestBody, evarMap) {<br>    var evars = {};<br>    for (var i = 0; i &lt; requestBody.length; i++) {<br>        var entry = requestBody[i];<br>        var evarName = evarMap[entry.name + &#39;rating&#39;];<br>        if (evarName) {<br>            evars[evarName] = entry.rating;<br>        }<br>        var evarName = evarMap[entry.name + &#39;navigationType&#39;];<br>        if (evarName) {<br>            evars[evarName] = entry.navigationType;<br>        }<br>    }<br>    return evars;<br>}<br><br>const queue = new Set();<br>function addToQueue(metric) {<br>    queue.add(metric);<br>}<br><br>function flushQueue() {<br>    if (queue.size &gt; 0) {<br>        try {<br>            const requestBody = [...queue];<br><br>            // set the s.events object<br>            s.events = returnEventsString(requestBody, eventMap)<br><br>            // for the events in the event string, set s.linkTrackEvents to a comma separeated list of the events<br>            s.linkTrackEvents = s.events.split(&#39;,&#39;).map(function (event) {<br>                return event.split(&#39;=&#39;)[0];<br>            }).join(&#39;,&#39;);<br><br>            // set the evars<br>            evars = returnEvars(requestBody, evarMap);<br>            for (var evarName in evars) {<br>                if (evars.hasOwnProperty(evarName)) {<br>                    // set evar<br>                    s[evarName] = evars[evarName];<br>                    // add to linkTrackVars<br>                    s.linkTrackVars = s.linkTrackVars ? s.linkTrackVars + &#39;,&#39; + evarName : evarName;<br>                    _satellite.logger.log(&quot;Core Web Vitals Handler: s.&quot; + evarName + &quot; set to&quot;, s[evarName]);<br>                }<br>            }<br><br>            // call function to send data to Adobe<br>            s.tl(true, &#39;o&#39;, &#39;Core Web Vitals&#39;);<br><br>            //console logging<br>            _satellite.logger.log(&quot;Core Web Vitals Handler: requestBody&quot;, requestBody);<br>            _satellite.logger.log(&quot;Core Web Vitals Handler: event sent&quot;);<br><br>            queue.clear();<br>        } catch (err) {<br>            _satellite.logger.log(&quot;Core Web Vitals Handler: error&quot;, err);<br>        }<br>    }<br>}<br><br>webVitals.onCLS(addToQueue);<br>webVitals.onFID(addToQueue);<br>webVitals.onLCP(addToQueue);<br>webVitals.onFCP(addToQueue);<br>webVitals.onTTFB(addToQueue);<br>webVitals.onINP(addToQueue);<br><br>// Report all available metrics whenever the page is backgrounded or unloaded.<br>addEventListener(&#39;visibilitychange&#39;, () =&gt; {<br>    if (document.visibilityState === &#39;hidden&#39;) {<br>        flushQueue();<br>    }<br>});<br><br>// NOTE: Safari does not reliably fire the `visibilitychange` event when the<br>// page is being unloaded. If Safari support is needed, you should also flush<br>// the queue in the `pagehide` event.<br>addEventListener(&#39;pagehide&#39;, flushQueue);</pre><h3>Adobe Analytics Setup</h3><p>Lastly, you’ll want to enable the relevant custom Events and eVars in Adobe Analytics.</p><p>You’ll also want to create a Calculated Metric for each to give you the average score as a metric. That way you’ll be able to get an average score for dates, pages, or other dimensions in Adobe. For example;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/1*3X12U6pwEg8obZUo8l7LRg.png" /><figcaption>Average LCP Rating</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*SLo_u0rnVI7OOv9tRmcSUA.png" /><figcaption>Average LCP rating over time</figcaption></figure><h3>Wrapping Up</h3><p>And there you go! Hopefully all the works and you have Core Web Vitals tracked in Adobe Analytics using only custom code in Adobe Launch.</p><h3>About Us</h3><p><a href="http://www.station10.co.uk/">Station10</a> believe in open source and sharing knowledge and our Medium content is never paywalled, so please leave a clap if you’ve found this useful. This helps motivate us to write more content and gives us a better idea of what to write more about.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=538e03a9ea17" width="1" height="1" alt=""><hr><p><a href="https://medium.com/station10/tracking-core-web-vitals-in-adobe-analytics-538e03a9ea17">Tracking Core Web Vitals in Adobe Analytics</a> was originally published in <a href="https://medium.com/station10">Station10</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Approaches to implementing Adobe Analytics via AEP Web SDK and Adobe Launch]]></title>
            <link>https://medium.com/station10/approaches-to-implementing-adobe-analytics-via-aep-web-sdk-and-adobe-launch-46574b76c5f1?source=rss-e9fdf415d908------2</link>
            <guid isPermaLink="false">https://medium.com/p/46574b76c5f1</guid>
            <category><![CDATA[adobe-experience-platform]]></category>
            <category><![CDATA[adobe-launch]]></category>
            <category><![CDATA[aep-web-sdk]]></category>
            <category><![CDATA[adobe-analytics]]></category>
            <category><![CDATA[web-analytics]]></category>
            <dc:creator><![CDATA[Steve Webb]]></dc:creator>
            <pubDate>Mon, 27 Nov 2023 14:01:39 GMT</pubDate>
            <atom:updated>2024-01-26T11:45:09.963Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Implementing Adobe Analytics via the new AEP Web SDK methodology presents a number of challenges and it isn’t entirely clear what best practice looks like. There are a few different ways to approach it in Adobe Launch, so I’m going to run through some of them here and hopefully give you some good ideas for how to handle your own implementation!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gBf6ZfK1DbcoyKEgk5LIjQ.png" /><figcaption>Mandatory DALL-E generated image</figcaption></figure><h3>Some assumptions</h3><p>This blog assumes that…</p><ul><li>You’ve got a data layer, preferably an <a href="https://jimalytics.com/tag-management/the-event-driven-data-layer/">event-driven one</a>. The examples I’ll use here make use of either <a href="https://developers.google.com/tag-platform/tag-manager/datalayer">Google’s standard dataLayer object</a> or Adobe’s <a href="https://github.com/adobe/adobe-client-data-layer">Adobe Client Data Layer</a>. Both of which have useful Launch extensions.</li><li>You’re implementing AEP Web SDK using Adobe’s tag manager (Launch, Data Collection, Tags, or whatever it’s called this week).</li></ul><p>The examples in this blog also assume you’re sending the data to Adobe Analytics using the <a href="https://experienceleague.adobe.com/docs/experience-platform/xdm/field-groups/event/analytics-full-extension.html?lang=en">Adobe Analytics ExperienceEvent Schema</a> (so that your data is automatically mapped to the old evars, props, etc, without having to worry about Processing Rules.) But a lot of this blog applies to tracking data in any Schema, and should still be useful for anyone sending data to the <a href="https://experienceleague.adobe.com/docs/platform-learn/data-collection/web-sdk/overview.html?lang=en">Edge Network</a>, be it for Customer Journey Analytics, Real-Time CDP, or other products.</p><h3>The basics</h3><p>What we need to achieve in Adobe Launch is to map our data layer to the XDM Schema, and send off the right data at the right time.</p><p>Assuming you’ve already got a basic set of Data Elements defined that reference your data layer or other data points, the basic building block for this is the <a href="https://experienceleague.adobe.com/docs/experience-platform/tags/extensions/client/web-sdk/data-element-types.html?lang=en#xdm-object">XDM Object</a> data element. This allows us to map Data Elements to fields in the Schema:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Os8v0OawW78ZIPKWIDv1hg.png" /><figcaption>Mapping ‘screen url’ to eVar2</figcaption></figure><p>You’ll notice that we’ve already hit our first oddity, in that we now have 2 levels of Data Elements:</p><ul><li>One set that reference fields in our data layer. In the example above I’m using the Google Data Layer Extension to create data elements that reference fields in the dataLayer object.</li><li>A second set that maps those fields to the XDM Schema. In the example above I’m mapping screen.screenURL from my data layer to eVar1 in the Schema.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c9mCqst7uiSNPFnSIBARFg.png" /><figcaption>Data Elements into Data Elements</figcaption></figure><p>This is still pretty simple though; we have our XDM object with some info about the page, which we can then send off in a Rule.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*ML8kwtYmdI8NWFa-9bcIzA.png" /><figcaption>Sending our XDM Data Element off to the Edge network</figcaption></figure><p>This is slightly different to what you might be used to if you’re familiar with implementing Analytics using the Analytics extension: Previously you’d map your data elements to evars and props in a Rule action, whereas now you build your XDM object in a Data Element and then all you do is send off that one Data Element.</p><h3>The problem with Metrics</h3><p>So far this seems relatively straightforward, but things get a little more complicated when we have to start setting metrics in the Schema.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*91ucdIo3Rr1EHLzFSFndcA.png" /><figcaption>Setting the Page Views metric</figcaption></figure><p>We need to set web.webPageDetails.pageViews.value to ‘1’ for Analytics to treat this event as a page view (the equivalent of a legacy s.t() call). But that means I now can’t use this XDM Data Element for any other non-page view events.</p><p>Say, I’ve also got a ‘CTA Click’ event. I <em>don’t</em> want to set pageViews.value to ‘1’ in this scenario. And I might want to set some custom event like event1 as well. To track this properly, I need to set both _experience.analytics.event1to100.event1.value to ‘1’ <em>and</em> ensure that the web.webInteractions.linkClicks.value and type are set correctly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*927_pdNY3zMblTEkIkEJEA.png" /><figcaption>Setting event1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*Hx7IRyYeCEP6iQCcwjvtAA.png" /><figcaption>Making sure Adobe treats this as a ‘custom link’ event rather than a ‘page view’ event</figcaption></figure><p>So now, because we need separate XDM Object Data Elements for different events, do we need one XDM Object per event? Well probably…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HBje-3G26_OmZR4mn1gq6g.png" /><figcaption>Suddenly we have a lot of XDM Data Elements</figcaption></figure><p>There are a few things we can do though, so that this doesn’t get too unwieldy.</p><h3>The ‘Merge Object’ Data Element</h3><p>In many implementations, there are some data points that you want to set on every event, regardless of what it is. Things like URL info, customer IDs or maybe technical details like the <a href="https://experienceleague.adobe.com/docs/experience-platform/tags/extensions/client/core/overview.html?lang=en#runtime-environment">Launch library build date</a>. Setting all of those in every XDM data element is a lot of repeated work and is susceptible to mistakes.</p><p>There is a way around this with the ‘<a href="https://experienceleague.adobe.com/docs/experience-platform/tags/extensions/client/core/overview.html?lang=en#merged-objects">Merged Objects</a>’ Data Element type, provided by the Core extension. This takes in multiple JSON objects and merges them into a single object. And since the XDM objects are just JSON under the hood, we can use this to merge them together.</p><p>So, instead of having to set the same things all over the place, one solution is to:</p><ul><li>Create a ‘global’ XDM Object that contains all the dimensions that we want to set on every event.</li><li>Create individual XDM objects for individual events, with the relevant dimensions and metrics set.</li><li>Merge them together before sending them off to Adobe.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PxyvEuDnbwYVJUAGGYi13g.png" /><figcaption>The Merge Objects data element</figcaption></figure><p>Now, I’m not super happy with this solution… while it does reduce the amount of repeated work, we also end up with <em>another</em> layer of Data Elements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*jEztjl3UYq23OjzKil13Jg.png" /><figcaption>Turtles all the way down</figcaption></figure><h3>The new Update Variable rule action</h3><p>Adobe recently added a new <a href="https://experienceleague.adobe.com/docs/experience-platform/tags/extensions/client/web-sdk/data-element-types.html?lang=en#variable">Variable</a> data element and <a href="https://experienceleague.adobe.com/docs/experience-platform/tags/extensions/client/web-sdk/action-types.html?lang=en#update-variable">Update Variable</a> action to the AEP Web SDK extension. To me, this is a little frustrating because it has a lot of potential but I think it’s poorly implemented (actually see edit below, changed my mind.)</p><p>This takes us back to the old Adobe Analytics extension days where we map data to dimensions in the Actions rather than the Data Elements. Firstly we create a ‘Variable’ data element, which is just a reference to a Schema.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M-rqiw6HgNJ1MLCEyk4YqA.png" /><figcaption>A ‘Variable’ Data Element</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SkVWpdIh-hC9Li-QKDRHxg.png" /></figure><p>Then in our actions, we can update this ‘Variable’ before sending it to off to Adobe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SkVWpdIh-hC9Li-QKDRHxg.png" /></figure><p>This seems like a good approach, except for the fact you have to start with a <em>blank</em> schema every time. So while it removes the need for layers of Data Elements, we do still end up setting a lot of the same dimensions repeatedly.</p><p>I think this could be improved a lot if we could start with an existing XDM Data Element and update that, rather than starting from scratch every time. I wrote a lengthy post on the <a href="https://experienceleaguecommunities.adobe.com/t5/adobe-experience-platform-ideas/feature-request-the-new-update-variable-action-in-the-aep-web/idi-p/628858">Experience League Community</a> with suggested improvements if you want to check it out and give it a thumbs up!</p><p><strong>Edit 04/12/2023: </strong>As you might see from that Experience League thread, it was pointed out that you can actually provide an XDM data element at the root of the ‘Update variable’ action. So you <em>can</em> effectively start off with an existing XDM object and update that, which is very useful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*brmRloSQrtSRjVg43vkgEw.png" /><figcaption>Providing an entire XDM object at the root of an ‘Update Variable’ action</figcaption></figure><h3>Custom Code</h3><p>One final option that requires a bit more skill with JavaScript but solves a lot of these issues, is to just do a lot of the work in custom code. Normally I try to avoid too much custom code in my Launch implementations because it makes them less transparent and harder to maintain, but I think it makes sense here given the lack of better solutions.</p><p>One of the things we can do in the XDM Data Element fields is to just ‘provide entire object’. This means we can use a Custom Code Data Element here to provide chunks of the Schema, so long as it returns a JSON object in the correct format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bgf3EVXKKipAtFd0FxOjeA.png" /></figure><p>An area where custom code makes a lot of sense is for tracking ecommerce dimensions and events. It’s likely you’ll need to write custom code anyway to transform your data layer into the <a href="https://experienceleague.adobe.com/docs/analytics/implementation/vars/page-vars/products.html?lang=en#products-using-the-web-sdk">right format</a> for the productListItems object, so we might as well make good use of it.</p><p>As an example, here’s some script that converts a standard GA4 ecommerce.items data layer object into the right format for the XDM Schema and sets some additional merchandised eVars:</p><pre>function convertEcommerceItems(eventModel) {<br>    const ecommerce = eventModel.ecommerce;<br><br>    if (!ecommerce || !ecommerce.items) return [];<br><br>    return ecommerce.items.map(item =&gt; {<br>        let quantity = item.quantity        <br>        let productDetails = {<br>            SKU: item.item_id,<br>            productCategories: [{ categoryID: item.item_category }],<br>            quantity: quantity,<br>            priceTotal: item.price * quantity,<br>            _experience: {<br>                analytics: {<br>                    customDimensions: {<br>                        eVars: {<br>                            eVar20: item.item_name, // merchandised evar<br>                            eVar21: item.item_brand, // merchandised evar<br>                        }<br>                    }<br>                }<br>            }<br>        };<br><br>        return productDetails;<br>    });<br>}<br><br>return convertEcommerceItems(event.event.eventModel);</pre><p>This script makes use of the event.event.eventModel object that’s provided by the <a href="https://experienceleague.adobe.com/docs/experience-platform/tags/extensions/client/google-data-layer/overview.html?lang=en">Google Data Layer Extension</a>, and is one that we can reuse across different e-commerce events.</p><p>Likewise, we can also use custom code to set our events. Again, this is particularly useful in e-commerce scenarios to set the XDM commerce object, with all the <a href="https://experienceleague.adobe.com/docs/analytics/implementation/vars/page-vars/events/events-overview.html?lang=en">default fields that get mapped to the old Analytics e-commerce events.</a></p><pre>function produceCommerceObject(eventModel) {<br>    const eventType = eventModel.event;<br>    const ecommerce = eventModel.ecommerce;<br><br>    if (eventType === &#39;view_item&#39; || eventType === &#39;view_item_list&#39;) {<br>        return { productViews: { value: 1 } }; // Increments the Product Views metric<br><br>    } else if (eventType === &#39;remove_from_cart&#39;) {<br>        return { productListRemovals: { value: 1 } }; // Increments the Basket Removals metric<br><br>    } else if (eventType === &#39;add_to_cart&#39;) {<br>        return { productListAdds: { value: 1 } }; // Increments the Basket Adds metric<br><br>    } else if (eventType === &#39;view_cart&#39;) {<br>        return { productListViews: { value: 1 } }; // Increments the Basket Views metric<br><br>    } else if (eventType === &#39;begin_checkout&#39;) {<br>        return { checkouts: { value: 1 } }; // Increments the Checkouts metric<br><br>    } else if (eventType === &#39;purchase&#39;) {<br>        return {<br>            purchases: { value: 1 }, // Increments the Orders metric.<br>            order: {<br>                currencyCode: ecommerce.currency, // Sets the currencyCode variable<br>                purchaseID: ecommerce.transaction_id, // Sets the purchaseID variable<br>            }<br>        };<br><br>    } else {<br>        return {}; // default return if event type doesn&#39;t match any known types<br>    }<br>}<br><br>return produceCommerceObject(event.event.eventModel);</pre><p>Again, this script makes use of the event.event.eventModel object and maps the standard GA4 e-commerce data layer events to Adobe’s Analytics Schema.</p><p>Taking this approach can reduce the number of XDM Data Elements that we need, as the custom code can handle setting the right events depending on which dataLayer event triggered the Rule.</p><h3>Wrapping Up</h3><p>To be honest I’m not entirely happy with any of these approaches, they all have slight drawbacks and none of them are as neat as I’d like. Am I over-complicating this and is there a simpler approach that I’ve missed? I’m not sure there is, but let me know if you disagree!</p><p>Either way, hopefully, this has been useful to outline some different techniques that you can put to good use in your own implementations.</p><p><a href="http://www.station10.co.uk/">Station10</a> believe in open source and sharing knowledge and our Medium content is never paywalled, so please leave a clap if you’ve found this useful. This helps motivate us to write more content and gives us a better idea of what to write more about.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46574b76c5f1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/station10/approaches-to-implementing-adobe-analytics-via-aep-web-sdk-and-adobe-launch-46574b76c5f1">Approaches to implementing Adobe Analytics via AEP Web SDK and Adobe Launch</a> was originally published in <a href="https://medium.com/station10">Station10</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating Adobe Analytics usage data in Analysis Workspace]]></title>
            <link>https://medium.com/station10/automating-adobe-analytics-usage-data-in-analysis-workspace-2184439a2fa4?source=rss-e9fdf415d908------2</link>
            <guid isPermaLink="false">https://medium.com/p/2184439a2fa4</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[adobe-analytics]]></category>
            <dc:creator><![CDATA[Steve Webb]]></dc:creator>
            <pubDate>Sat, 26 Aug 2023 10:16:12 GMT</pubDate>
            <atom:updated>2023-08-29T14:34:59.934Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BXrpIiPEcwlsijXhwQW3Ig.png" /><figcaption>Nice to see usage of Analytics on the up!</figcaption></figure><h3>Analytics on your Analytics users</h3><p>Adobe Analytics gives you great data on how your customers are using your website, but what if you want to know about how your internal <em>users</em> are using Adobe Analytics?</p><p>A few years ago Adobe published <a href="https://express.adobe.com/page/hnYfQPThMu2dr/">a blog here</a> on how to get data on your Adobe Analytics usage into Adobe Analytics as a data source. In a nutshell, it shows how you can export the usage logs out of Adobe Analytics, do a bunch of data wrangling, and then import it <em>back</em> into Adobe Analytics as a data source.</p><h3>What’s it useful for?</h3><p>Data on how your users are using Adobe Analytics can help justify your investment in Adobe Analytics (can you tell this part is copied from the Adobe blog), it can show the results of training sessions, and tell you who your power users are. You could answer business questions like:</p><ul><li>How many users are accessing Analytics over time?</li><li>Are more users accessing Adobe after we delivered training sessions?</li><li>Who are our power users?</li><li>What are the most popular projects or segments?</li><li>Who deleted my workspace?!</li></ul><p>If you want more info on the sorts of things you can do with this data, go ahead and read the <a href="https://express.adobe.com/page/hnYfQPThMu2dr/">Adobe blog</a> on the subject. It goes into much more detail than I will here.</p><h3>Automating the process</h3><p><strong>So here is the interesting bit: The previous method was very manual and required that you do a lot of the data extraction, transforming, and enriching yourself. I’ve automated pretty much all of it (although you still need to re-run this script on a regular basis to add new data).</strong></p><p>I’ve recently been trying to increase my skills with Python and the Adobe APIs, to try and automate some of the more repetitive parts of my job. Like a lot of people, I’ve found in the last few months that ChatGPT (specifically GPT-4) has massively increased my ability to output working code. So I figured automating this process would be an excellent use case.</p><p>To that end, I’ve written a Python script that mostly automates the entire process outlined in Adobe’s blog. The code and a more detailed explanation of the script can be found in a public GitHub repository here: <a href="https://github.com/station-10/adobe-usage-import-public">https://github.com/station-10/adobe-usage-import-public</a></p><p>But here’s a brief summary of the process:</p><h3>How it works</h3><h4>Connect to the Adobe APIs</h4><p>You’ll need a developer account with access to the <a href="https://developer.adobe.com/console/home">Adobe Developer Console</a> for your organisation to create an API project with access to Analytics. More details on getting started with the APIs can be found <a href="https://developer.adobe.com/analytics-apis/docs/2.0/guides/">here</a>.</p><h4>Downloading the data</h4><p>The script will download the Adobe usage logs for a specific date range, from the <a href="https://developer.adobe.com/analytics-apis/docs/2.0/guides/endpoints/usage/">Usage API Endpoint</a>. That endpoint has an annoying 3 month limit on the date range for each call, so the function handles making multiple requests if you specify a longer date range.</p><h4>Enriching the data</h4><p>The usage log data comes out looking like this:</p><pre>{<br>  &quot;eventType&quot;: 31,<br>  &quot;eventDescription&quot;: &quot;Project Updated: Name=Marketing Channel TEST Project Id=64365d1e723ea728686e1970 Owner=Stephen Webb&quot;,<br>  &quot;ipAddress&quot;: &quot;XX.XX.XXX.XXX&quot;,<br>  &quot;login&quot;: &quot;steve.webb@station10.co.uk&quot;,<br>  &quot;rsid&quot;: &quot;N/A&quot;,<br>  &quot;dateCreated&quot;: &quot;2023-04-14T08:32:15.000+00:00&quot;<br>},</pre><p>There is some good information here, but we can do a couple of things to make the data even more useful for us:</p><ol><li>The eventType can be converted to a friendly name.</li><li>We can pull information out of the eventDescription for easier reporting on things like categories of events (e.g. ‘Project Viewed’ in the example above), and component information.</li><li>We should definitely scrub the email address and remove the domain part of it.</li><li>We can add event numbers for setting in s.events and using for metrics in Analytics.</li></ol><p>So after all that we end up with data that looks like this:</p><pre>{<br>  &quot;eventType&quot;: &quot;Workspace Project&quot;,<br>  &quot;eventDescription&quot;: &quot;Project Updated: Name=Marketing Channel TEST Project Id=64365d1e723ea728686e1970 Owner=Stephen Webb&quot;,<br>  &quot;ipAddress&quot;: &quot;XX.XX.XXX.XXX&quot;,<br>  &quot;login&quot;: &quot;steve.webb&quot;,<br>  &quot;rsid&quot;: &quot;N/A&quot;,<br>  &quot;dateCreated&quot;: &quot;2023-04-14T08:32:15.000+00:00&quot;,<br>  &quot;event&quot;: &quot;event3&quot;,<br>  &quot;componentName&quot;: &quot;Marketing Channel Costs Project&quot;,<br>  &quot;componentId&quot;: &quot;64365d1e723ea728686e1970&quot;,<br>  &quot;componentOwner&quot;: &quot;Stephen Webb&quot;<br>},</pre><p>The benefit of doing all this now, is that we can avoid having to set up Processing Rules and regex Classifications in the Adobe interface, as the original blog suggests.</p><h4>Converting to CSV</h4><p>We then need to convert it to a CSV file for importing via the <a href="https://developer.adobe.com/analytics-apis/docs/2.0/guides/endpoints/bulk-data-insertion/">Bulk Data Insertion</a> endpoint. At this point we need to add a few mandatory fields:</p><ul><li>reportSuiteID</li><li>Timestamp</li><li>marketingCloudVisitorID</li><li>s.pageName</li><li>userAgent</li></ul><p>And we end up with a .csv file that looks something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uXhpHy8kHpN2aFCm.png" /></figure><h4>Data validation</h4><p>Uploading data into Adobe Analytics is relatively straightforward, however, <strong>removing</strong> data is not. The <a href="https://developer.adobe.com/analytics-apis/docs/2.0/guides/endpoints/data-repair/">Data Repair API</a> exists but we really don’t want to have to use it, so we should be very careful with the data we want to upload.</p><p>With that in mind, we can do a couple of things:</p><p>Firstly, we can do a few checks on the data to ensure it looks sensible. Things like graphing the data over time and confirming it starts and ends at the dates we expect:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/0*RqvtLlrqFxrbiHK5.png" /></figure><p>Secondly, we can validate the .csv file against the <a href="https://developer.adobe.com/analytics-apis/docs/2.0/guides/endpoints/bulk-data-insertion/endpoints/#validate">Validation</a> endpoint, and confirm we get a successful response:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/0*gw_3gULKeixdey0p.png" /></figure><h4>Creating a report suite to put the data in</h4><p>At this point we need to create a report suite to put the data in. This is one part I haven’t yet automated, but its very possible to do via the Analytics APIs, so something for a future update. Creating 30+ events in the Adobe Admin UI is a minor chore but for now, check out the README file on <a href="https://github.com/station-10/adobe-usage-import-public">GitHub</a> for the evars and events that you’ll need to set up.</p><h4>Inserting the data</h4><p>Now we’re ready to insert the data. This is done using the <a href="https://developer.adobe.com/analytics-apis/docs/2.0/guides/endpoints/bulk-data-insertion/endpoints/#primary-ingestion-endpoint">Bulk Data Insertion</a> Endpoint. Again, because I’m nervous about inserting data, this function performs a couple of checks:</p><ol><li>It includes a check against the validation endpoint mentioned above.</li><li>It also performs a request to Adobe Analytics to check if there is any existing data in the date range of the .csv file. Just in case you accidentally try to upload data for the same date range twice.</li></ol><p>Provided both of those checks pass, it’ll upload the file. An hour or so later, you should see all your Adobe usage logs as data in Adobe Analytics!</p><h3>Next Steps</h3><p>I won’t talk too much about how to use the data in Workspace; Adobe’s blog already does a good job of that and I’m sure if you’ve read this far, you already know how to create a decent dashboard.</p><p>Otherwise my next plan for this would be to automate the process in an ongoing fashion. Currently this script will handle inserting all your historic data in one go, but you’ll need to re-run the script to insert new data as time goes on. The script does make that an easy process, but why click a few buttons every week when you could automate it completely.</p><h3>Useful Links</h3><p><a href="https://express.adobe.com/page/hnYfQPThMu2dr/">Original Adobe Blog</a></p><p><a href="https://developer.adobe.com/analytics-apis/docs/2.0/guides/endpoints/usage/">Usage API Endpoint documentation</a></p><p><a href="https://developer.adobe.com/analytics-apis/docs/2.0/guides/endpoints/bulk-data-insertion/">Bulk Data Insertion API Endpoint documentation</a></p><p><a href="https://github.com/station-10/adobe-usage-import-public">GitHub Repo</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2184439a2fa4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/station10/automating-adobe-analytics-usage-data-in-analysis-workspace-2184439a2fa4">Automating Adobe Analytics usage data in Analysis Workspace</a> was originally published in <a href="https://medium.com/station10">Station10</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>