fdgfsdas

Embed Size (px)

Citation preview

  • 7/27/2019 fdgfsdas

    1/17

    Adobe Marketing Cloud

    Adobe Analytics Data Insertion API

  • 7/27/2019 fdgfsdas

    2/17

    Contents

    Data Insertion API.............................................................................................................3

    Overview...............................................................................................................................................................................3

    Data Insertion Process...............................................................................................................................................................................3

    Visitor Identification...................................................................................................................................................................................4

    Sequential Data Requirements..............................................................................................................................................................5

    Delayed Data.................................................................................................................................................................................................5

    HTTP 1.1..........................................................................................................................................................................................................6

    Limitations.....................................................................................................................................................................................................6

    Reference..............................................................................................................................................................................6

    Supported XML Tags and Query Variables........................................................................................................................................7

    POST Response Codes.............................................................................................................................................................................10

    Sample Code.....................................................................................................................................................................11

    HTTP POST Sample...................................................................................................................................................................................11

    HTTP GET Sample......................................................................................................................................................................................13

    Data Insertion Sample (PHP).................................................................................................................................................................14

    Data Insertion Sample (Java)................................................................................................................................................................15

    Data Insertion Sample (Python)...........................................................................................................................................................17

    Adobe Analytics Data Insertion APILast updated 9/24/2013

  • 7/27/2019 fdgfsdas

    3/17

    Data Insertion APIThe Data Insertion API supports HTTP POST and HTTP GET for submitting data to Adobe Marketing Cloud servers.

    Overview

    The Data Insertion API provides a mechanism for server-side data collection and submission to Marketing Cloud servers.Instead of using JavaScript beacons on each Web page to transmit visitor data to Online Marketing Suite servers, server-side

    data collection collects data based solely on Web browser requests and Web server responses.

    While this data capture method cannot capture all data that is available via page-based beacons, it provides valuable insight into

    user activity on your Web pages without the overhead associated with attaching a JavaScript beacon to every Web page.

    Data Insertion Process

    The Data Insertion API supports HTTP POST and HTTP GET for submitting data to Adobe Marketing Cloud servers.

    Note: The Analytics response to each data insertion includes a status message (SUCCESS orFAILURE).

    HTTP POST

    Use an HTTP POST to submit properly-formatted Data Insertion XML to the Data Insertion URL. The Data Insertion URL

    differs from the standard JavaScript data submission URL. Adobe ClientCare can provide the domain name of the Adobe data

    collection servers where you should send data. For example:

    http://namespace.112.2o7.net/b/ss//6

    http://namespace.122.2o7.net/b/ss//6

    Note: The "6" code at the end of the URL indicates that the data submission requires XML processing.

    Upon receipt, Adobe servers perform basic tag validation of the data insertion. If it encounters an error, Adobe returns a Failure

    response. If the data insertion is successful, Adobe queues the data insertion request for processing by the standard Analytics

    Data Processing Engine. The engine processes these requests in the same way it processes data collected via JavaScript.

    When using HTTP POST with the Data Insertion API, consider the following:

    The Data Insertion API requires data in UTF-8 format. Specify the character encoding in the opening XML tag, as shown in

    XML Data Insertion Format.

    Replace Ampersand (&), greater-than (>), and less-than (

  • 7/27/2019 fdgfsdas

    4/17

    Microsoft .Net Framework version 1.1 supports the HTTP header: Expect: 100-Continue in HTTP POST requests,

    but Marketing Cloud servers reject POST data sent with this type of request. To avoid this, set

    ServicePointManager.Expect100Continue = False. For more information, see

    http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemnetservicepointmanagerclassexpect100continuetopic.asp .

    HTTP GET

    Use an HTTP GET to submit data to the Data Insertion URL in a query-string format that supports shortened variable names(for more information, see "Variables and Query String Parameters" in theAnalytics Implementation Guide, available at Help

    > Documentation in the Marketing Cloud.

    HTTP GET reduces bandwidth needs by 30% - 40%, but Adobe data collection servers do not send response messages, so if the

    data insertion doesn't work as expected, you do not have that feedback for troubleshooting purposes. For more information,

    see the HTTP GET Sample.

    The Data Insertion URL differs from the standard JavaScript data submission URL. The in the URL is the report suite

    where you want to submit the data. Adobe ClientCare can provide the domain name of the Adobe data collection servers where

    you should send data. For example:

    http://namespace.112.2o7.net/b/ss//0

    http://namespace.122.2o7.net/b/ss//0

    Note: The "0" code at the end of the URL indicates that the data submission requires JavaScript processing. For example:

    Upon receipt, Adobe servers perform basic tag validation of the data insertion. If it encounters an error, Adobe returns a Failure

    response. If the data insertion is successful, Adobe queues the data insertion request for processing by the standard Analytics

    Data Processing Engine. The engine processes these requests in the same way it processes data collected via JavaScript.

    Note: The Data Insertion API requires data in UTF-8 format.

    Visitor Identification

    To track site visitors, each visitor must have a unique visitor ID. Ideally, this is a persistent cookie with an extended expirationperiod (5 years or more.)

    Use the visitorID tag, the combination of IP address and userAgent, to submit visitor ID information to Adobe data

    collection servers. The visitorID variable supports up to 100 alpha-numeric characters and cannot contain a hyphen.

    If the data insertion includes a visitorID, the Analytics Data Processing Engine assumes that persistent cookies are enabled

    for the visitor's Web browser. If the data insertion identifies visitors using IP address/User Agent, Analytics displays persistent

    cookies for that visitor as disabled.

    Note:

    To avoid processing problems, make sure thatvisitorID

    is a uniformly distributed random number.

    The visitorID is critical for linking a visitor's activities captured via JavaScript with those submitted through tagless data

    collection, or a third-party application. For example, to link a visitor's browsing activity with transactions in a third-party

    shopping cart application, you must pass the visitorID to the shopping cart application. The shopping cart application uses

    the visitorID when uploading transaction data via the Data Insertion API so Analytics can link the transaction data to the

    visitor's browsing activity (previously captured via JavaScript).

    4Data Insertion API

    http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemnetservicepointmanagerclassexpect100continuetopic.asphttp://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemnetservicepointmanagerclassexpect100continuetopic.asp
  • 7/27/2019 fdgfsdas

    5/17

    Typically, the client systems generate unique visitor identifiers that you can use as the visitorID value. We recommend

    generating your own visitor id, in both the XML and in the JavaScript so that the values match.

    Sequential Data Requirements

    To ensure accurate visitor pathing and commerce data, applications must send visitor data in the order it was received.

    The Analytics Data Processing Engine closes a visit after 30 minutes without receiving data.

    When simulating previously recorded traffic, Adobe recommends that data insertions mimic the time delays between visitor

    events on the site. For example, if the application records page views for a given visitor 2, 4, and 5 seconds apart, send those

    page views to Analytics using the same cadence.

    If the application cannot mimic the original event timing, Adobe recommends sending sequential data insertions 3 seconds

    apart, per visitor, to help avoid out-of-order data processing.

    Delayed Data

    By using the Data Insertion API, you can submit delayed data (for example, from an offline application, to Adobe data collectionservers.

    Note: Data from delayed submissions is available to Data Warehouse and Ad hoc analysis.

    When submitting delayed data, you must send visitor data in the order it was received, (see Sequential Data Requirements) but

    you do not need to send data for different visitors in any specific order. For example, you can submit all data for visitor A before

    data for visitor B, even if some or all of visitor B data occurred before visitor A data.

    Submitting delayed data requires an additional tag in the XML. Analytics discards data without a timestamp.

    Note:

    To view time-stamped hits, Adobe ClientCare must enable time-stamp support on the report suite, in addition to the

    time-stamp variable that you set. Time-stamped hits sent to a report suite that has not been enabled do not appear in the

    report.

    Format the timestamp data, including time zone, using either the Unix timestamp format or the ISO-8601 format. For example,

    using the ISO-8601 format, a timestamp for a visitor event that occurred on November 17, 2009 at 5:33 PM Mountain Time

    (GMT-7:00:00) is as follows:

    2009-11-17T17:33:22-07

    Consider the following when submitting delayed (time-stamped) data:

    While a report suite is collecting time-stamped data, it cannot collect data through the standard JavaScript beacon method.

    You must enable time stamp support on a per-report-suite basis.

    When submitting data delayed by more than 30 minutes, do so without any pauses in the data transmission to make sureAnalytics processes it as a single visit. Analytics might process delayed data as separate visits if there is more than a 100-second

    pause between transmission batches.

    You can also use Data Sources to send this type of data to the Marketing Cloud via FTP. For more information, see the Data

    Sources User Guide.

    5Data Insertion API

    http://microsite.omniture.com/t2/help/en_US/sc/datasources/oms_sc_data_sources.pdfhttp://microsite.omniture.com/t2/help/en_US/sc/datasources/oms_sc_data_sources.pdfhttp://microsite.omniture.com/t2/help/en_US/sc/datasources/oms_sc_data_sources.pdfhttp://microsite.omniture.com/t2/help/en_US/sc/datasources/oms_sc_data_sources.pdf
  • 7/27/2019 fdgfsdas

    6/17

    HTTP 1.1

    Adobe data collection servers support HTTP 1.1.

    Using HTTP 1.1, you can send multiple POST requests in a single session. However, when using HTTP 1.1, be aware of the

    following:

    While a report suite is collecting time-stamped data, it cannot collect data through the standard JavaScript beacon method.

    Adobe data collection servers limit the number of HTTP requests per HTTP session. To account for this, make sure your

    application can detect closed sessions and respond appropriately.

    Adobe data collection servers observe HTTP 1.1 rules when chunking content. Make sure your application properly interprets

    the chunking numbers provided in the Online Marketing Suite server response to your data insertion. For example, in the

    following HTTP 1.1 response, the numbers 68 and 0 are chunking numbers, which represent the number of bytes to read

    before the next chunk.

    TTP/1.1 200 OK Date: Thu, 07 Dec 2008 15:48:51 GMT Expires: Wed, 06 Dec 2008 15:48:51 GMTLast-Modified: Fri, 08 Dec 2008 15:48:51 GMT Cache-Control: no-cache, no-store, must-revalidate,max-age=0, proxy-revalidate, no-transform, private Pragma: no-cache ETag:

    "457837E3-649A-4BBB9314" Vary: * P3P: policyref="/w3c/p3p.xml", CP="NOI DSP COR NID PSA OURIND COM NAV STA" Transfer-Encoding: chunked Content-Type: text/xml 68 FAILURE NO pagename OR pageurl 0

    Limitations

    There are some limitations to server-side data collection when compared to client-side data collection using JavaScript.

    Server-side data collection cannot collect Web browser configuration data.

    Server-side data collection cannot collect ClickMap data.

    Server-side data collection loses cached page navigation data because using a Web browser's back button or reloading a cached

    page does not generate additional server requests or responses. This limits pathing data available for Analytics reports.

    Typically, bots do not run JavaScript when requesting a page, and do not request the page's image tags. However, server-side

    data collection includes requests from bots and spiders.

    You must have control over the servers from which you want to collect data. If you use a Content Delivery Network (CDN)such as Akamai* to deliver web pages, the server-side data collection described here cannot collect data for those pages.

    If you control most of your Web site pages, but use some third-party services (for example, surveys or shopping cart systems),

    server-side data collection cannot collect data from the third-party pages. You should use JavaScript tagging on third-party

    pages that request content from your Web servers to gain visibility into those systems.

    Server-side data collection alone cannot provide cross-domain tracking of site visitors. However, you can use the

    tag in conjunction with client-side JavaScript data collection to pass additional information to the server. This is the only way

    that cross-domain tracking is possible when using a .

    Server-side data collection can co-exist with a client-side (JavaScript) implementation only if clients submit server-side data

    in near real-time. If clients have a JavaScript beacon implementation, and want to collect server-side data and submit it in

    batches, they should use Data Sources, not the Data Insertion API.

    Reference

    Data insertion API reference topics.

    This section contains details on supported XML tags and POST response codes.

    6Data Insertion API

  • 7/27/2019 fdgfsdas

    7/17

    Supported XML Tags and Query Variables

    When processing HTTP POST data submissions, only values in supported XML tags are processed. When submitting HTTPGET data submissions, only specified query string and HTTP header variables are processed.

    The following table lists all supported XML tags, along with their associated query string variable equivalents and HTTP header

    variable equivalents, where applicable. The JavaScript variable column is provided for reference.

    Every data insertion must include either and/or .

    Every data insertion must also include either and/or .

    DescriptionHTTP Header

    Var

    JavaScript

    Variable

    Query String Parameter

    (GET)XML Tag (POST)

    Browser height in pixels (For

    example, 768).

    N/AN/Abh

    Browser width in pixels (For

    example, 1024).

    N/AN/Abw

    The campaign tracking code

    associated with the page.

    N/Acampaignv0

    The page title or bread crumb.N/Achannelch

    Monitor color depth in bits (For

    example, 24).

    N/AN/Ac

    Visitor's connection type ("lan" or

    "modem").

    N/AN/Act

    Key-values pairs are specified in one

    of the following formats:

    N/AcontextDatac.[key]

    red

    or:

    red

    Each of these examples result in a

    context data value ofmy.a = red.

    Multiple key-value pairs can bespecified.

    In the query string, this context data

    variable would appear as

    c.my.a=red

    7Data Insertion API

  • 7/27/2019 fdgfsdas

    8/17

    DescriptionHTTP Header

    Var

    JavaScript

    Variable

    Query String Parameter

    (GET)XML Tag (POST)

    Whether the visitor supports first

    party session cookies (Y or N).

    N/AN/Ak

    Revenue currency code Forexample, USD.

    N/AcurrencyCode

    cc

    Analytics eVar.N/AeVar1 - eVar75v#

    For example, v2.

    For example,

    .

    A list of Analytics events.N/Aeventsevents

    A hierarchy string.N/Ahier1 - hier5h#

    For example, h2

    For example,

    .

    Whether the current page is the

    visitor's homepage (Y or N).

    N/AN/Ahp

    The visitor's IP address.X-Forwarded-ForN/AN/A

    Whether the visitor has Java enabled

    (Y or N).

    N/AN/Av

    JavaScript version. For example, 1.3.N/AN/A

    j

    The browser's supported language.

    For example, "en-us".

    Accept-LanguageN/AN/A

    Name of link.N/AlinkNamepev2

    Type of link ("d", "e", or "o").N/AlinkTypepe

    The link's HREF. For custom links,

    page values are ignored.

    N/AlinkURLpev1

    A delimited list of values that are

    passed into a variable, then reported

    N/Alist1 - list3l#

    For example,

    . as individual line items for

    reporting.

    The Web page name.N/ApageNamepageName

    8Data Insertion API

  • 7/27/2019 fdgfsdas

    9/17

    DescriptionHTTP Header

    Var

    JavaScript

    Variable

    Query String Parameter

    (GET)XML Tag (POST)

    The Web page type. This is only

    used on 404 error pages. Set

    N/ApageTypepageType

    pageType to "Error Page" for when

    a 404 error is detected.

    The Web page URL For example,

    http://www.mysite.com/index.html.

    N/ApageURLg

    Semicolon separated list of Netscape

    plug-in names.

    N/AN/Ap

    List of all products on the page.

    Separate products with a comma.

    N/Aproductsproducts

    For example: Sports;Ball;1;5.95,

    Toys; Top;1:1.99.

    Analytics property name.N/Aprop1 - prop75c#

    For example, c2

    For example,

    Purchase ID number.N/ApurchaseIDpurchaseID

    The URL of the page referrer.N/AN/Ar

    Specifies the report suites where you

    want to submit data. Separate

    N/As_accountContained in the URL. See

    HTTP GET Sample.

    multiple report suite IDs with a

    comma.

    Monitor resolution For example,

    1280x1024.

    N/AN/As

    Analytics XML request version

    number. For example, 1.0.

    N/AN/AN/A

    The Web server serving the page.N/Aserverserver

    The visitor's U.S. state.N/Astatestate

    The time and date on which the

    data was collected.

    N/Atimestampts

    9Data Insertion API

  • 7/27/2019 fdgfsdas

    10/17

    DescriptionHTTP Header

    Var

    JavaScript

    Variable

    Query String Parameter

    (GET)XML Tag (POST)

    XML POST: Visitor's time zone

    offset from GMT in hours. For

    example, -8.

    N/AN/APart of the t parameter

    GET: The visitor's time zone isincluded in the t query string

    parameter, which contains the local

    time. The t parameter is in the

    following format:

    dd/mm/yyyy hh:mm:ss DOFFSET

    Where D is a number in the range

    0-6 specifying the day of the week,

    and OFFSET represents:

    offset from GMT in hours *

    60 * - 1

    For example:

    09/23/2013 14:00:00 1 420

    Common value used to tie

    multi-channel user activities

    N/AtransactionIDxact

    together for reporting purposes. For

    more information, see the Data

    Sources User Guide.

    The visitor's browser type and OS.User-AgentN/AN/A

    Visitor's unique identifying cookie.

    See "Visitor Information" in

    N/AN/Avid

    "Understanding the Data Insertion

    API".

    The visitor's zip code.N/Azipzip

    POST Response Codes

    The Data Insertion API supports these response messages to HTTP POST operations.

    The following table lists all supported XML tags, along with their associated JavaScript variable equivalents and HTTP header

    variable equivalents, where applicable.

    ponse messages can help you understand and correct the problem.

    10Data Insertion API

    http://microsite.omniture.com/t2/help/en_US/sc/datasources/oms_sc_data_sources.pdfhttp://microsite.omniture.com/t2/help/en_US/sc/datasources/oms_sc_data_sources.pdfhttp://microsite.omniture.com/t2/help/en_US/sc/datasources/oms_sc_data_sources.pdfhttp://microsite.omniture.com/t2/help/en_US/sc/datasources/oms_sc_data_sources.pdf
  • 7/27/2019 fdgfsdas

    11/17

    DescriptionPOST Response

    Success (general)SUCCESS

    Failure (general)FAILURE

    Failure (missing required report suite id)FAILURE NO

    account

    Failure (missing required page name or

    page URL)

    FAILURE NO pagename

    OR pageurl

    Failure (missing required visitor id or IP

    address)

    FAILURE NO

    visitorid OR ipaddress

    Failure (syntax error: includes malformed

    XML, non-encoded reserved characters,etc.)

    FAILURE Syntax

    Error

    Sample Code

    The Data Insertion API includes these code samples.

    Note: Do not copy-and-paste these code samples. They use generic values that you must replace with valid data appropriateto your application.

    HTTP POST Sample

    This sample displays the structure of an HTTP POST request and response using the Data Insertion API.

    Note: Do not copy-and-paste these code samples. They use generic values that you must replace with valid data appropriateto your application.

    The [rsid] parameter identifies the report suite where you want to submit the data. Other values, such as PageURL, are sample

    values only.

    HTTP 1.0 POST Request

    POST /b/ss//6 HTTP/1.0Host: [rsid].112.2o7.netContent-Length: 593

    1.0apps.sillystring.com/summary.dohttp://apps.sillystring.com/summary.do192.168.10.1summary14911

    11Data Insertion API

  • 7/27/2019 fdgfsdas

    12/17

    Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727;Media Center PC 5.0; .NET CLR 3.0.04506)

    Brazil12865564209665141302009-03-05T01:00:01-05[rsid]

    HTTP POST Response

    HTTP/1.1 200 OKDate: Wed, 13 May 2009 16:26:47 GMTX-C: ms-3.7.2Expires: Tue, 12 May 2009 16:26:47 GMTLast-Modified: Thu, 14 May 2009 16:26:47 GMTCache-Control: no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform,private

    Pragma: no-cacheETag: "4A0AF4C7-08E1-37C7F492"Vary: *P3P: policyref="/w3c/p3p.xml", CP="NOI DSP COR NID PSA OUR IND COM NAV STA"xserver: www79Connection: closeContent-Type: text/xmlSUCCESS

    HTTP 1.1 POST Request

    POST /b/ss//6 HTTP/1.1Host: [rsid].112.2o7.netKeep-Alive: timeout=15Connection: Keep-AliveContent-Length: 593

    1.0apps.sillystring.com/summary.dohttp://apps.sillystring.com/summary.do192.168.10.1summary14911Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727;

    Media Center PC 5.0; .NET CLR 3.0.04506)Brazil12865564209665141302009-03-05T01:00:01-05[rsid]

    HTTP 1.1 POST Response

    HTTP/1.1 200 OKDate: Wed, 13 May 2009 16:25:12 GMTX-C: ms-3.7.2Expires: Tue, 12 May 2009 16:25:12 GMT

    Last-Modified: Thu, 14 May 2009 16:25:12 GMTCache-Control: no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform,private

    Pragma: no-cacheETag: "4A0AF468-4DF2-33AE9089"Vary: *P3P: policyref="/w3c/p3p.xml", CP="NOI DSP COR NID PSA OUR IND COM NAV STA"xserver: www116Keep-Alive: timeout=15Connection: Keep-AliveContent-Length: 40Content-Type: text/xml

    12Data Insertion API

  • 7/27/2019 fdgfsdas

    13/17

    SUCCESS

    HTTP GET Sample

    This sample displays the structure of an HTTP GET request and response using the Data Insertion API.

    The [rsid] parameter identifies the report suite where you want to submit the data. Other values, such as PageURL, are samplevalues only.

    Note: Do not copy-and-paste these code samples. They use generic values that you must replace with valid data appropriateto your application.

    HTTP 1.0 GET Request

    GET /b/ss/[rsid]/0?g=apps.sillystring.com%2Fsummary.do&r=http%3A%2F%2Fapps.sillystring.com%2Fsummary.do&ip=192.168.10.1&gn=summary&v2=14911&c10=Brazil&vid=1286556420966514130&ts=2009-03-05T01%3A00%3A01-05 HTTP/1.0Host: [rsid].112.2o7.netX-Forwarded-For: 192.168.10.1

    HTTP 1.0 GET Response

    HTTP/1.0 200 OKDate: Wed, 13 May 2009 16:26:47 GMTX-C: ms-3.7.2Expires: Tue, 12 May 2009 16:26:47 GMTLast-Modified: Thu, 14 May 2009 16:26:47 GMTCache-Control: no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform,private

    Pragma: no-cacheETag: "49F5FD79-3E44-38021808"Vary: *P3P: policyref="/w3c/p3p.xml", CP="NOI DSP COR NID PSA OUR IND COM NAV STA"xserver: www83Connection: closeContent-Type: text/html

    HTTP 1.1 GET Request

    GET /b/ss/[rsid]/0?g=apps.sillystring.com%2Fsummary.do&r=http%3A%2F%2Fapps.sillystring.com%2Fsummary.do&ip=192.168.10.1&gn=summary&v2=14911&c10=Brazil&vid=1286556420966514130&ts=2009-03-05T01%3A00%3A01-05HTTP/1.1

    Host: [rsid].112.2o7.netKeep-Alive: timeout=15Connection: Keep-AliveX-Forwarded-For: 192.168.10.1

    HTTP 1.1 GET Response

    HTTP/1.1 200 OKDate: Mon, 19 Oct 2009 17:26:24 GMT

    Server: Omniture DC/2.0.0X-C: ms-4.1.3Expires: Thu, 01 Jan 1970 00:20:55 GMTLast-Modified: Thu, 01 Jan 1970 00:20:56 GMTCache-Control: no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform,private

    Pragma: no-cacheETag: "4ADCA140-6E16-1FADA4C7"Vary: *P3P: policyref="/w3c/p3p.xml", CP="NOI DSP COR NID PSA OUR IND COM NAV STA"xserver: www176Content-Length: 43

    13Data Insertion API

  • 7/27/2019 fdgfsdas

    14/17

    Keep-Alive: timeout=15Connection: Keep-AliveContent-Type: image/gif

    Data Insertion Sample (PHP)

    This PHP sample illustrates how to connect to Adobe data collection servers and record a page view.

  • 7/27/2019 fdgfsdas

    15/17

    // get response$response="";while( !feof($fp) ){$response .= fgets($fp,1028);

    }fclose($fp);

    // display resultsecho "RESULTS:\n";

    print_r($response);echo "\n";

    // check for errorsif( preg_match("/status\>FAILURE\

  • 7/27/2019 fdgfsdas

    16/17

    buff.append( "1.0\n" );

    if( this.rptSuiteID != null )buff.append( this.tagify( "reportsuiteid", this.rptSuiteID ) );

    if( this.visitorID != null )buff.append( this.tagify( "visitorid", this.visitorID ) );

    Iterator iter = this.request.iterator();

    while( iter.hasNext() ){

    buff.append( iter.next() );}buff.append( "\n" );

    return buff.toString();}

    private String tagify( String name, String value ){

    return "" + value + "\n";}

    private String tagify( String name, char value ){

    return "" + value + "\n";}

    public void set( String tag, String value ){

    this.request.add( this.tagify(tag, value) );}

    public void set( String tag, char value ){

    this.request.add( this.tagify(tag, value) );}

    }

    DataSubmission.javapackage com.omniture;

    import java.io.BufferedReader;import java.io.DataOutputStream;import java.io.InputStreamReader;import java.net.URL;import java.net.URLConnection;

    public class DataInsertionRequest{

    public static void main(String[] args) throws Exception{

    DataInsertion di = new DataInsertion( "test", "123456" );di.set( "ipaddress", "127.0.0.1" );di.set( "pagename", "Test Page" );

    di.set( "channel", "Tests" );di.set( "prop1", "All" );di.set( "events", "event1" );di.set( "evar2", "Test Page" );di.set( "evar3", "Test Page" );di.set( "evar4", "Test Page" );di.set( "hier1", "Test|Test Page|All" );

    URL url = null;URLConnection urlConn = null;DataOutputStream printout = null;

    16Data Insertion API

  • 7/27/2019 fdgfsdas

    17/17

    BufferedReader input = null;String u = "http://namespace.112.2o7.net/b/ss/ll/6";String tmp = null;

    url = new URL( u );urlConn = url.openConnection();urlConn.setDoInput( true );urlConn.setDoOutput( true );urlConn.setUseCaches( false );urlConn.setRequestProperty( "Content-Type", "application/x-www-form-urlencoded"

    );

    printout = new DataOutputStream(urlConn.getOutputStream());

    printout.writeBytes( di.toString() );printout.flush();printout.close();

    input = new BufferedReader( new InputStreamReader( urlConn.getInputStream() ) );

    System.out.println( di );while( null != ( ( tmp = input.readLine() ) ) ){

    System.out.println( tmp );}

    printout.close();input.close();

    }

    }

    Data Insertion Sample (Python)

    This Python sample illustrates how to access the Data Insertion API.

    import httplib

    xml=' 1.0Corp1_rs

    2010-03-20T10:33:22-07 16910.0.0.1 Test Page'

    conn = httplib.HTTPConnection("namespace.112.2o7.net:80")conn.request("POST", "/b/ss//6",xml )response = conn.getresponse()print(response.status, response.reason)print(response.read())

    17Data Insertion API