Adobe-Marketing-Cloud / marketing-cloud-php-sdk

PHP Library for the Adobe Digital Marketing API
MIT License
35 stars 32 forks source link

segments #4

Closed cacos8 closed 10 years ago

cacos8 commented 10 years ago

I'm trying to build a report with segments(inline segements) but I`m not able. This the response I'm writing, where is the error? (thanks):

$response = $reportApi->queueTrended(array(
    'reportSuiteID' => 'xxxxxxx',
    'date'     => date('2014-03'),  
    'metrics'  => array(
        array('id' => 'pageviews'),
        //array('id'=> 'visits')
    ),
    'elements' => array(
        array('id' => 'browser'),
    ),
    'dateGranularity'=>'day',
    'segments'=> array('id'=>'page','selected'=>array("Home Page","Shopping Cart")),
));
bshaffer commented 10 years ago

Hey @cacos8! Thanks for reporting this. Your report definition looks great. Can you tell us what the error you are seeing is?

cacos8 commented 10 years ago

Hi Brent, "Invalid segment" is the error. I tried to make ir without segments and it works. Is when I use the segment when the error happens.. El 05/03/2014 18:09, "Brent Shaffer" notifications@github.com escribió:

Hey @cacos8 https://github.com/cacos8! Thanks for reporting this. Your report definition looks great. Can you tell us what the error you are seeing is?

Reply to this email directly or view it on GitHubhttps://github.com/Adobe-Marketing-Cloud/marketing-cloud-php-sdk/issues/4#issuecomment-36766733 .

cacos8 commented 10 years ago

Hi Brent, The error Message is: Fatal error: Uncaught exception 'AdobeDigitalMarketing_Api_ReportError' with message 'Invalid segment' in /var/www/adobe/apiadobe/lib/AdobeDigitalMarketing/Api/Report.php:202 Stack trace: #0 /var/www/adobe/apiadobe/lib/AdobeDigitalMarketing/Api/Report.php(84): AdobeDigitalMarketing_Api_Report->returnResponse(Array) #1 /var/www/adobe/index.php(106): AdobeDigitalMarketing_Api_Report->getReport(235049648) #2 {main} thrown in /var/www/adobe/apiadobe/lib/AdobeDigitalMarketing/Api/Report.php on line 202

bshaffer commented 10 years ago

Try changing "id" to "element" in the "segments" array

bshaffer commented 10 years ago

This changed with version 1.4 of the APIs, and I'm guessing this must be your issue

cacos8 commented 10 years ago

Hi Brent, Bad news, I tried changing "id"/"element" in the segments array and It doesn't works... same error... I don`t know what I'm doing wrong...

bshaffer commented 10 years ago

Aha, I see the problem. Your segments property needs to be an array of segments, rather than a single Inline Segment. So you should submit the report definition like this:

$response = $reportApi->queueTrended(array(
    'reportSuiteID' => 'xxxxxxx',
    'date'     => date('2014-03'),  
    'metrics'  => array(
        array('id' => 'pageviews'),
        //array('id'=> 'visits')
    ),
    'elements' => array(
        array('id' => 'browser'),
    ),
    'dateGranularity'=>'day',
    'segments'=> array(
        array(
            'id'=>'page',
            'selected'=>array("Home Page","Shopping Cart"
        )
    ),
));

Let me know if that fixes your problem

cacos8 commented 10 years ago

HI Brent, It works! thank you for your time!

CarlosMLebrón (@analisisweb) mi libro: "_#AWconGA 2.0:Analítica web con Google Analytics"_http://analisis-web.blogspot.com.es/p/manual-de-google-analytics.html?utm_source=firma_email&utm_medium=email&utm_campaign=libro http://analisis-web.blogspot.com http://analisis-web.blogspot.com http://analisis-web.es http://analisis-web.es

2014-03-12 17:07 GMT+01:00 Brent Shaffer notifications@github.com:

Aha, I see the problem. Your segments property needs to be an array of segments, rather than a single Inline Segment. So you should submit the report definition like this:

$response = $reportApi->queueTrended(array( 'reportSuiteID' => 'xxxxxxx', 'date' => date('2014-03'), 'metrics' => array( array('id' => 'pageviews'), //array('id'=> 'visits') ), 'elements' => array( array('id' => 'browser'), ), 'dateGranularity'=>'day', 'segments'=> array( array( 'id'=>'page', 'selected'=>array("Home Page","Shopping Cart" ) ),));

Reply to this email directly or view it on GitHubhttps://github.com/Adobe-Marketing-Cloud/marketing-cloud-php-sdk/issues/4#issuecomment-37427283 .

flashbng commented 10 years ago

@bshaffer Does this SDK include a function for GetSegments? I opened the ReportSuite.php file and it looks like getMetrics and getElements are present, but not segments. I can give it a shot at writing it myself, but wanted to confirm before hand.

https://marketing.adobe.com/developer/en_US/documentation/omniture-administration/r-getsegments-2

bshaffer commented 10 years ago

@flashbng yes, it's not part of the library (yet), but you can call it like this:

$response = $adm->getSuiteApi()->post('ReportSuite.GetSegments', array(
    'rsid_list' => array('my.rsid')
));

It would be pretty simple to add it, we just haven't done it yet.

flashbng commented 10 years ago

@bshaffer Thank you! Quick question about a similar error I'm getting as the OP:

Code:

response = $reportApi->QueueOvertime(array( 'reportSuiteID' => $report_suite, 'dateFrom' => date($window_begin), 'dateTo' => date($window_end), 'metrics' => array( array('id' => $metrics), ), 'segment_id' => $segment, ));

fetch response from query

$reportId = $response['reportID'];

do { $report = $reportApi->getReport($reportId); sleep(2); } while ($report['status'] == 'not ready');

Where $metric = array('visitors'); and $window_begin & $window_end are dates, $segment_id is an array of segment id's in the form of "541d3ed6e4b0748a2cxxxxxx". The error I get after looping through this code after some time is as following:

Fatal error: Uncaught exception 'AdobeDigitalMarketing_Api_ReportError' with message 'Invalid report ID' in /Applications/MAMP/htdocs/Omniture_API/omniture_sdk/lib/AdobeDigitalMarketing/Api/Report.php:202 Stack trace: #0 /Applications/MAMP/htdocs/Omniture_API/omniture_sdk/lib/AdobeDigitalMarketing/Api/Report.php(84): AdobeDigitalMarketing_Api_Report->returnResponse(Array) #1 /Applications/MAMP/htdocs/Omniture_API/omniture_fillDB_v2.php(62): AdobeDigitalMarketing_Api_Report->getReport(240941386) #2 {main} thrown in /Applications/MAMP/htdocs/Omniture_API/omniture_sdk/lib/AdobeDigitalMarketing/Api/Report.php on line 202

Any thoughts?