Code Samples
  • 29 Nov 2021
  • 1 Minute to read
  • Contributors
  • Dark
    Light
  • PDF

Code Samples

  • Dark
    Light
  • PDF

Article summary

Understanding the code samples for the Data Collection API.

To illustrate Data Collection API usage, we have provided sample client code in a variety of programming languages. The clients are scripts or console mode applications that send data to collection servers. Developers are not limited to the languages or libraries mentioned here. If you can send an HTTP POST, you can send data to the Data Collection API.

You can download the code samples here.

Content of Sample Code

Each client performs the following actions:

  • Composes the URIs needed to access the Data Collection API
  • Encodes the POST body containing customer data to send to the Data Collection API
  • Calls the Data Collection API to obtain a visitor id (/ids.svc)
  • Calls the Data Collection API to submit customer data (/events.svc)
  • Writes results to standard output

HTTP Client Libraries

Each sample client makes use of a language-specific HTTP client library to facilitate the HTTP POST requests. Developers familiar with web programming will recognize the HTTP libraries employed in the samples.

LanguageHTTP Client Library
C#System.Web.HTTPWebRequest
Javajava.net.HttpURLConnection
Pythonurllib2
RubyNet::HTTP
PerlLWP::UserAgent
HTML<form></form>

Was this article helpful?