Implement Data Providers to integrate third-party data into 51黑料不打烊 Target
Implementation details and examples of how to use 51黑料不打烊 Target鈥檚 Data Providers feature to retrieve data from third-party data providers and pass it in the Target request.
at.js
1.3 or aboveImplement the Basic Components of Data Providers
A quick overview of the basic components of a dataProvider
and how to get your code in the right order.
A working example with the code used in the video can be found here:
Integrate with a Third-Party API
OK, so let鈥檚 take a look at a more realistic example that incorporates a third party API call to provide the information that we wanted to pass to Target. So we鈥檙e going to open up this second example. And now if you look at my Network tab you鈥檒l see there are, there鈥檚 an additional request. And here we see this call to the weather API. That鈥檚 responding with all types of information about the weather. It鈥檚 raining here where I am and you鈥檒l see that there is weather information that gets passed in the Target request. This weather condition parameter in this weather details parameter. So let鈥檚 take a look at the source code and see what鈥檚 going on here. So it鈥檚 very similar to our simple static example, at.js is the last thing we鈥檙e defining our Target Global settings calling-in this data provider called Weather Provider.
Weather Provider is up here and you鈥檒l see there鈥檚 quite a bit more happening in that provider itself. One thing to notice, I鈥檝e set a timeout here since it involves this third party request. The data providers will hold up the Target request for as long as your timeout setting. The default is two seconds. You can make that higher, you can make it lower and the Target request will wait until the provider comes back or this timeout is reached. At.js will manage Flicker while waiting for this third party call. So here I鈥檓 just I鈥檓 forcing in the latitude and longitude. So this isn鈥檛 going to show your local weather, it鈥檚 going to be the weather in the New York City area. But here here is where I鈥檓 making my request to the third party, making an Ajax Json request and you鈥檒l see in the Success function here鈥檚 where my callback function is for the data provider. So again, in that first argument for the error we鈥檙e passing null again.
You鈥檒l see in the area handling we are using that first parameter, the first argument of the function call. But then the meat of it I鈥檓 passing these two parameters in the Target request and I鈥檓 reading out these particular fields from my weather API response. So, this is again a more realistic example and you鈥檒l see these dynamic parameter values end up in my Target request.
A more realistic example, integrating a weather API.
A working example with the code used in the video can be found here:
Integrate with Multiple Providers
How to incorporate data from multiple providers into your global Target request.
A working example with the code used in the video can be found here:
Minimize Page Load Impact
Minimize the impact on page load time by storing data in a session storage object. Alternatively, you could pass the values as profile parameters using the profile.
prefix, and just pass them in the first Target request of the session. However, you would be limited to passing fifty profile parameters per request.
A working example with the code used in the video can be found here: