ConversionTrackerService returns incorrect TotalNumEntries?

35 views
Skip to first unread message

Christopher Parotat

unread,
Jul 20, 2020, 12:04:41 PM7/20/20
to AdWords API and Google Ads API Forum

Hi,
I try to fetch the conversion-types from the ConversionTrackerService, but the TotalNumEntries is always limited to the given page-size. For example in my Test-Account I have 4 existing conversions. When i set the page-size to 1 the returned TotalNumEntries is also 1, with page-size 2 the TotalNumEntries is also 2, and so on. With a larger page-size than the actual number of existing conversions the returned TotalNumEntries is correct.

Im using the PHP api and based the following code on the "Get all campaigns" example code:

    public function getConversionTypes(): array
    {
        $pageSize = 2;

        $conversionTrackerService = $this->getService(ConversionTrackerService::class);

        $startIndex = 0;

        $selector = new Selector(['Id', 'Name']);
        $selector->setOrdering([new OrderBy('Name', SortOrder::ASCENDING)]);
        $selector->setPaging(new Paging($startIndex, $pageSize));

        $totalNumEntries = 0;
        $conversionTypes = [];
        do {
            $page = $conversionTrackerService->get($selector);

            if ($page->getEntries() !== null) {
                $totalNumEntries = $page->getTotalNumEntries();
                foreach ($page->getEntries() as $conversionType) {
                    $conversionTypes[] = $conversionType;
                }
            }

            $selector->getPaging()->setStartIndex(
                $selector->getPaging()->getStartIndex() + $pageSize
            );
        } while ($selector->getPaging()->getStartIndex() < $totalNumEntries);

        return $conversionTypes;
    }

Am I misunderstading the purpose of TotalNumEntries or is that a bug?

Regards,
Christopher

Google Ads API Forum Advisor Prod

unread,
Jul 20, 2020, 5:30:18 PM7/20/20
to c.pa...@betterbusiness.com, adwor...@googlegroups.com
Hi Christopher,

Specifying the paging will limit the number of entities that are returned. If you specify a large number, you should have all the conversions in your account returned. 

Cheers,
Anthony
Google Ads API Team

ref:_00D1U1174p._5004Q22XZOx:ref

Christopher Parotat

unread,
Jul 21, 2020, 4:50:13 AM7/21/20
to AdWords API and Google Ads API Forum
Hi Anthony,

Thanks for the quick reply. But shouldn't the returned "TotalNumEntries" be always 4 in my example, regardless of the page-size?
I tried it with the CampaignService and it does return the correct TotalNumEntries (= total number of campaigns in the account) for any page-size; the ConversionTrackerService on the other hand does not.

I can workaround that issue by changing the pagination code or just using a huge page-size.
But given that the adapted example code for the CampaignService (where i only changed the service's name) does not work for the ConverstionTrackerService looks to me like the ConversionTrackerService does not work as intended.

Thanks,
Christopher

Google Ads API Forum Advisor Prod

unread,
Jul 21, 2020, 2:52:59 PM7/21/20
to c.pa...@betterbusiness.com, adwor...@googlegroups.com
Hi Christopher,

Can you please share with me both the logs for CampaignService and ConversionTrackerService where you saw this behavior via reply privately to author so I can take a closer look?

Thanks,
Reply all
Reply to author
Forward
0 new messages