Adobe Analytics & CJA in Google Tag Manager (via Web SDK)

Ever want to know how to implement AA & CJA in GTM via WebSDK? Okay, that’s a lot of abbreviations. Maybe this time in English – do you wanna send data to Adobe from Google Tag Manager? Yes? Wonderful! Let’s go through the steps to do that.

Step 1: Create a Schema

You should be using XDM, so let’s create our schema. Don’t use too many brain cells and just create one using Adobe Analytics ExperienceEvent Template.

Basic AEP Schema

Cool, now we can pass in page data and other basic stuff.

Step 2: Create a Dataset

We need to create a dataset for CJA. All the schema did was say “This is what stuff should look like when the data is sent to some endpoint.” We haven’t yet set up the endpoint. Open up Experience Platform and click on Datasets. Then assign your dataset to the schema you just created. The dataset is what it sounds like – some set of data. We need to have a place for the data to go before we route it via the datastream.

Add Dataset

Step 3: Create a Datastream

I mean, we need to tell the data where it’s supposed to go, so head to Adobe Data Collection (launch.adobe.com) and create a new Datastream.

AEP Datastream Basics

After this interface, you’ll want to assign it to the Adobe Analytics service:

Add Datastream Service

This basically says “send the data here.” You may have a few report suites you send the data to. You’ll probably want to create a separate stream for staging. Now that we have Adobe Analytics configured – let’s add CJA:

Add CJA Service

The Datastreams screen should now look like this:

AA and CJA Datastreams

Step 4: Create an Alloy.js Tag in GTM

Here’s the documentation. Now ignore 99% of it and just paste this code into a Custom HTML tag in GTM:

<script>
  !function(n,o){o.forEach(function(o){n[o]||((n.__alloyNS=n.__alloyNS||
  []).push(o),n[o]=function(){var u=arguments;return new Promise(
  function(i,l){n[o].q.push([i,l,u])})},n[o].q=[])})}
  (window,["alloy"]);
</script>
<script src="https://cdn1.adoberesources.net/alloy/2.6.4/alloy.min.js" async></script>

<script>
  alloy("configure", {
    "edgeConfigId": "ebebf826-a01f-4458-8cec-ef61de241c93",
    "orgId":"ADB3LETTERSANDNUMBERS@AdobeOrg"
  });
</script>

You will update the edgeConfigId and the orgId. Put simply, it will literally look like this:

Configure Alloy Tag

If you’re used to Google Analytics, this is like setting the UAID (or GA4 account ID). You can find the edgeConfigId in the Datastreams section here:

Edge Configuration ID

Why do they call it Datastream ID here and Edge Configuration ID in the config code? No idea.

Step 5: Send data

Now let’s send some data when the page loads. To do this, we will be using this documentation. I created my own little snippet based on the schema.

alloy("sendEvent", {
  "xdm": {
    "web": {
      "webPageDetails": {
        "URL": document.location.href,
        "isErrorPage": {{Error Page}},
        "name": document.title,
        "server": "Some Server"
      }
    }
  }
});

You can see exactly where it lines up with our schema:

Alloy Schema Code

Okay, now let’s paste this into GTM so it triggers when every page loads:

Fire Alloy Tags in GTM

Yes, it’s that simple.

One note is that implementation via Google Tag Manager is a stop-gap until you can get everything into Launch (or Tags or Data Collection or whatever its name is today). If you plan to keep this tag in longer-term, keep in mind that the code above is for version 2.6.4. To get the latest library you’ll need to manually update it (copy/paste it again into GTM). One really cool thing Adobe does is maintain every version of their library. I think it’s cool, at least.

Final Thoughts

These are 5 remarkably simple steps that are hard to piece together if you’re doing this by yourself. I created videos of the ENTIRE process, step by step – there shouldn’t be much ambiguity here. During this entire process, I’ve been reminded of how much opportunity there is for Adobe to beef up their documentation and naming consistency.

Is it a Datastream ID? Is it an Edge Configuration ID?

Am I using Alloy? Am I using Web SDK?

Is this Datastream sending data to AEP? Or is it sending it to CJA?

Am I using XDM? Or is it Schemas?

I think this process could be so much more streamlined with small changes and some attention to detail. Anyway, I hope this helps.

5 thoughts on “Adobe Analytics & CJA in Google Tag Manager (via Web SDK)”

  1. Nice! Thanks, Jim!! And I couldn’t agree with you more regarding their need for consistency and attention to detail…

    Thanks for sharing!

    – Randy

    Reply
  2. Thanks for the article. I’m migrating a client to Adobe Analytics but they plan to have GA4 as a backup platform. What is your suggestion when it comes to tag management if both of these platforms need to be on the site?

    Reply

Leave a Comment