Implement Adobe Target Server Side - Part 2
Published on 02/07/2019
6 min read
A look into the basic server side API that is used to implement Adobe Target server side.
So, the actual Adobe documentation is quite intensive in terms of the detail, that it goes into and I'm not just going to sit here and read it for you but feel free to jump into it in your own time but there's essentially three ways of implementing Target server side, there is the server side delivery API v1 which is this one, this lets you query a single mbox and return the content from it.
There is the v2 which is the batch delivery API which is the one I personally use more or less all the time, because you can still return the content from one mbox as per this. But you can also return the content from multiple mbox if needs be. And the third way is the Node JS SDK which is what I'm going to demo in this this video. Now it is easier to use this but under the hood it's basically just making these same API calls, but it takes care of some of the kind of the finicky tasks that you don't have to really worry about. Like setting cookies and persistence and that type of thing which we will go into in detail later on.
But like I said under the hood this MarketingCloudClient.getOffer() is basically just invoking this API up here. And MarketingCloudClient.getOffers() is invoking this batch server side API. So, if we just click on either these links here let's just look at their the standard one because it's easy to explain. It takes you through to https://developers.adobetarget.com, and this is a great source of information to figure out exactly how server-side works. So, basically like I said just an API call and we make a call to the Target server from our server, and content is returned in the form of an object that we can manipulate and do whatever we want.
So, again not spending too much time on this because a lot of it is pretty simple. This button here this orange one is a series of Postman calls. So, a Postman for anyone not aware it's basically a piece of software which you can download which allows you to make API calls and requests whether that be GET, POST, PUT, DELETE, MODIFY whatever it may be. And you can see what is returned.
So, if we just give this a little click here and I've already got these, but anyway if I just click on Mac and I open Postman. So, I have these already because I've already been playing around with this. But what it does, it basically sets up a couple of requests for us to look at. So, the extent of what you can do with the API, it's huge if we take a look around you, can get reports from the API, look at audiences, offers and activities. You can do admin requests to change people's permissions to add users, but for the purposes of this today.
It's all just about the basic mbox call and how we return content is all you're really going to use on this unless you building some kind of dashboard. So, the initial request that we get in here it's pre-setup that makes a request using adobetargetmobile client code. So, this has been set by Adobe for us and if we just send this request, we'll get a response and you'll see you get a tntId. You get the edgeHost, the content which is “Use SHIPFREE to get free shipping” and then you get my session ID which is set from the actual URL itself.
Now obviously returning Adobe's content is good, but we want to return our own content. So, we have to modify this request slightly to get our own content. Things that are need to modified is client code, session ID, client code again and then the actual mbox that we're looking to get the content from. So, let's just go across here, and if I just go into to Target quickly and I've got a test that I've set-up earlier which is called “Server side testing”. Let's just jump into this anyway in case you were actually setting this up yourself.
So, the name of the mbox that you put in here can be anything you want it isn't global mbox at the minute. When you first set this up nothing will exist, because there has been no calls. So, call it something appropriate, A in my case has content and B has different content, it’s just a heading. So, A, is just my heading that says “London-based Adobe Target conversion optimisation agency”, which is a tagline from the company website that I have. And this is a separate one that says, “This is a server-side headline from Adobe Target”.
And if we just jump through its setup let's make it actually a 100% to B and then all visitors in this case because it's server-side. So, unless you call it, it can’t actually invoke, so it's not going to invoke on different URLs. And then I have just got a super basic set-up here it's just so reporting it to Adobe Target and it's just engagement and pageviews because it's the simplest way of setting it up. And if I just save and close this that was just to give you an overview of how that’s set up. If we jump into setup once these actually sync’s, we'll get our client code.
If you don't know how to get your client code, it sits under the implementation tab, so if you go implementation, edit settings and get your client code from here. So, if we just basically swap out the client code, and then here it's looking for this mbox. And I called mine servermbox1, just make sure it matches, its wrong. So, underscore test one, go back into postman. Okay, so now the only thing to setup here is the session ID, it can remain as is for now but what is key to know about this is when we run this later on the session ID needs to be unique per session.
So, that Target and the visitor ID service can link a session together and doesn't create multiple sessions, otherwise what potentially may happen is the server creates a visitor. And then once you land on the site, the visitor API service creates a visitor, and you've essentially got two visitors rather than the one, which would create a nightmare. But the purposes now we can leave it as is if I send this, I now get more or less the same thing. The ID is different but we now get the content which is from my Target test that I set up previously which is over here, and that just shows the same content as in B. So, this content here is the same as this content here. So, that is the basic call and we can make a more complex call. And again, the documentation over here has every single request parameter, some of them are required some of them aren’t and that gives you a lot of power. I'm not gonna go through all of these because it would take a long time and some of them are not used that much. But let's just look at the request with all of the parameters on.
So, this is essentially the same mbox call as previous, so my client ID and this time I'll just put an actual ID in here. And the body is modified this time, so what this is, I'm still looking at “servertest1”, but I'm passing parameters into the mbox. So, this could be anything, so you could pass in as you can see here it's passing in screen height, screen width blah blah blah, Could be anything, it could be, geolocation you could pass in here if you wanted and then use it in the actual Target interface itself. We're passing in page URL, referral URL, IP address, you can pass anything you want in here and that will allow you to target better or create and more niche audience if you need to its outside the scope of this but again I may cover it in a different video. When I run this, this time you send the post request. You're essentially just get the exact same thing, but what it's done it's sent off a lot of these parameters now to the mbox. And you could use them to Target, it's worth noting what can be done in here because it's pretty extensive.
It's unlikely you're gonna make many calls that are just the basic mbox call, but as you can see essentially you returned an object in both cases that's got a session ID from the URL and has content. So, now we could use this content on the server side, if we wanted to display inside a template which I'll demonstrate later on. But that kind of wraps it up for just you know what does Target do under the hood server side. Makes it very simple API call to the server. The server responds with a tntId, it responds to say it's got the session ID that we've set and gives you the content. It's kind of that simple.