segments.ad_network_type and segments.device results in numerical values

47 views
Skip to first unread message

sreenu malae

unread,
Apr 5, 2020, 3:17:00 AM4/5/20
to AdWords API and Google Ads API Forum
I'm trying to get the network type and device type from segments
 $query = 'SELECT campaign.idad_group.id,metrics.clicks,metrics.ctr,metrics.impressions,segments.ad_network_type,segments.device, ad_group.name FROM ad_group';
        
        if ($campaignId !== null) {
            $query .= " WHERE campaign.id = $campaignId";
        }

        // Issues a search request by specifying page size.
        $response =
            $googleAdsServiceClient->search($customerId$query, ['pageSize' => self::PAGE_SIZE]);
        
        // Iterates over all rows in all pages and prints the requested field values for
        // the ad group in each row.
        foreach ($response->iterateAllElements() as $googleAdsRow) {
            /** @var GoogleAdsRow $googleAdsRow */
            printf(
                "Ad group with ID %d Clicks %d Impressions %d CTR %d and name '%s' was found in campaign with ID %d and device '%s' network type '%s'.%s",
                $googleAdsRow->getAdGroup()->getId()->getValue(),
                $googleAdsRow->getMetrics()->getClicksUnwrapped(),
                $googleAdsRow->getMetrics()->getImpressionsUnwrapped(),
                $googleAdsRow->getMetrics()->getCtrUnwrapped(),
                $googleAdsRow->getAdGroup()->getName()->getValue(),
                $googleAdsRow->getCampaign()->getId()->getValue(),
                $googleAdsRow->getSegments()->getDevice(),
                $googleAdsRow->getSegments()->getAdnetworktype(),
                
                PHP_EOL
            );
        }
But i'm getting Numerical values like 1,2,3,4
Ad group with ID 77778102923 Clicks 0 Impressions 205 CTR 0 and name 'A - Videography' was found in campaign with ID 6501346749 and device '4' network type '3'.
Ad group with ID 77778102923 Clicks 2 Impressions 255 CTR 0 and name 'A - Videography' was found in campaign with ID 6501346749 and device '2' network type '3'.
Ad group with ID 98328817814 Clicks 1 Impressions 882 CTR 0 and name 'Remarketing' was found in campaign with ID 9715050198 and device 
'4' network type '4'.
Ad group with ID 98328817814 Clicks 2 Impressions 559 CTR 0 and name 'Remarketing' was found in campaign with ID 9715050198 and device 
'2' network type '4'.
Ad group with ID 98328817814 Clicks 0 Impressions 7 CTR 0 and name 'Remarketing' was found in campaign with ID 9715050198 and device '3' network type '4'

Google Ads API Forum Advisor Prod

unread,
Apr 6, 2020, 12:07:33 PM4/6/20
to sreen...@gmail.com, adwor...@googlegroups.com

Hi Sreenu,

Thank you for reaching out. Please refer to this source code for the representation of the number in the results of segments.device and this source code for the segments.ad_network_type, respectively. Please let me know if you have any further questions.

Thanks and regards,
Xiaoming, Google Ads API Team



 

ref:_00D1U1174p._5001UZWGSO:ref

sreenu malae

unread,
Apr 6, 2020, 1:58:36 PM4/6/20
to AdWords API and Google Ads API Forum

Hey Xiaoming, 


So you mean for Segment,Device i'm getting numerical values from this file.

But even if i delete whole code Device.php. still i'm getting numberical values.

Can you please help me Xiaoming.

Thanks and Regards,
Sreenivasulu 

sreenu malae

unread,
Apr 6, 2020, 2:00:27 PM4/6/20
to AdWords API and Google Ads API Forum

Same thing happens with  adnetworktype too.

Google Ads API Forum Advisor Prod

unread,
Apr 7, 2020, 10:32:54 AM4/7/20
to sreen...@gmail.com, adwor...@googlegroups.com

Hi Sreenu,

You would get the numerical values rather than the strings. You could just add a hashmap to correlate the numeric values and the strings based on the source code links I sent you earlier. Please let me know if you have any further concerns.



Thanks and regards,
Xiaoming, Google Ads API Team



 

ref:_00D1U1174p._5001UZWGSO:ref
Reply all
Reply to author
Forward
0 new messages