Use custom code in the Adobe Analytics extension in tags

Learn about use cases and technical considerations for using the custom code editor when configuring the Adobe Analytics extension in tags.

Transcript
Hey everybody, this is Doug. In this video I want to talk about the configure tracker using custom code section in the Analytics Extension in Launch. And so here we are in the Analytics Extension and before we jump into that section I just want to scroll up a little bit and show you that in the Library Management at the very top of this section here, there is a checkbox and it says “Make tracker globally accessible” and if we mouse over that info bubble there, it will let us know that it will scope the S object globally under windows.s. And so we definitely want to make sure that is checked, so that we can use the S object and call the S object in our custom code anywhere in our Launch property. So, make sure that that is selected. And then, I’ll scroll back down to this section that we’re gonna talk about, and open that, and there’s really just a couple of things. Now, before we jump into the editor window here, I just want to point out that you have to have the ability to run this custom code, either before or after other settings are applied. Now, what that means is, after these configuration settings are applied. This is all the configuration of the Analytics Extension, and the S object and so if you want this code to run before or after some of these other things like maybe before or after these Global Variables, you might set etcetera, then you can select that but by default it’ll say after other settings are applied and in most cases that’s gonna be just fine. Now, I’ll jump into Open Editor, and I’ve got some coding here just to kind of show you order of operations, we’ve got some code down here at the bottom is just kind of out of the open. I’m setting a variable called EVar3 and you can see I’m setting it to the AA extension, that’s Adobe Analytics extension, custom code window, so I’m just kinda setting it to where it’s being set and then basically the same thing for a console log here in the code window for AA extension. Now, above this I have this doPlugins function here, and basically this is a function that is built into App Measurement into the App Measurement Library but you do have to call it if you want to use it. And in many cases you will, in order to use some of the implementation plugins that can perform certain functions for you and set variables and do different things like that. And so in the documentation, I’ll just run up here to the documentation, you can just search for Plug-ins, you can also search for implementation plug ins to get a list of ones that are in the documentation there, or you can always talk to a consultant at Adobe and they can help you with some implementation plug ins as well. But here’s the code for the doPlugins function. And so you can go in here and you can get that and you can then copy and paste that right into this section. Now, the cool thing about doPlugins in this doPlugins function is that it will happen last and it will happen on every hit going into Adobe Analytics and so on every page view hit, on every custom link hit, this code will run and it will run last and so, if you are setting things a certain way somewhere else in a rule, or like I said, even outside of that here, you’ll want to know that this is gonna run last and I’ll just kinda show that by running this on a page, so you’ll see over here I have a test page and you’d think obviously here, that if this all ran in succession that it would set eVar3 to in doPlugins and then it would reset it to this value down here, and so when it goes in it would actually have this value down here, but again, it runs doPlugins last and so it’s going to this stuff last. Let’s take a look at that.
And I just refreshed this and so I don’t need to do that again but you’ll see that on this page where I was running I actually do have eVar3 set as in doPlugins and actually if I go over to the console log, then you can see that it ran in the code window for AA extension and then it ran in doPlugins and so basically, it’s just showing that it’s running that doPlugins function last, and so you can use this doPlugins function to run your implementation plugins and set different variables and do all those kinds of things. In another video we’ll show a really cool use case for that but again, just generally speaking, probably gonna want to use the doPlugins function, this is a great place to put it is in this custom code configuration section, in the Analytics Extension. Good luck.

Review the documentation for more information about the doPlugins function referenced in this video.

recommendation-more-help
b5d9c99f-be9f-4b96-8809-4e7d6ae353ba