Google ads - get campaign name with photo
I need to fetch:
- Name of the campaign.
- Impressions.
- Cost.
- Conversation Rate.
- Conversions.
- Date.
- Budget.
- Image/Video of this ad.
Can I fetch it all from campaign entity? How?
$googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient(); // Creates a query that retrieves all campaigns. $query = 'SELECT [MYLIST] FROM campaign ORDER BY campaign.name'; // Issues a search stream request. /** @var GoogleAdsServerStreamDecorator $stream */ $stream = $googleAdsServiceClient->searchStream($customerId, $query); // Iterates over all rows in all messages and prints the requested field values for // the campaign in each row. foreach ($stream->iterateAllElements() as $googleAdsRow) { /** @var GoogleAdsRow $googleAdsRow */ printf( "Campaign with ID %d and name '%s' was found.%s", $googleAdsRow->getCampaign()->getId(), $googleAdsRow->getCampaign()->getName(), AND SOMETHING HERE PHP_EOL ); }
There's no way to get an image of the ad back. But you can call the ads report and get the ad elements back and present it any way you like.
Me, I'd pull the ad content and use something like carbon to generate an image.