Upload offline adword conversion implementation in php

45 views
Skip to first unread message

navin bista

unread,
Dec 28, 2018, 3:30:33 AM12/28/18
to AdWords API and Google Ads API Forum
Hi Folks,

I am completely new to this google adword API, so please be patience with me. I am trying  to upload offline adword conversion through adword API and I am stuck here, so I hope someone could help me getting over it.

I have the required information like GCLID and other conversion data, what I need to do is just upload it to the adword account.

I am doing it on PHP so let me list out what i have done till now.

1. I have downloaded the PHP library using composer from https://github.com/googleads/googleads-php-lib 
2. I am referring https://developers.google.com/adwords/api/docs/guides/conversion-tracking#importing_conversions documentation. Here i found a code snippet that upload offline conversion

$offlineConversionService = $adWordsServices->get($session, OfflineConversionFeedService::class);


// Associate offline conversions with the existing named conversion tracker.
// If this tracker was newly created, it may be a few hours before it can
// accept conversions.
$feed
= new OfflineConversionFeed();
$feed
->setConversionName($conversionName);
$feed
->setConversionTime($conversionTime);
$feed
->setConversionValue($conversionValue);
$feed
->setGoogleClickId($gclid);


// Optional: To upload fractional conversion credits, set the external
// attribution model and credit. To use this feature, your conversion
// tracker should be marked as externally attributed. See
// https://developers.google.com/adwords/api/docs/guides/conversion-tracking#importing_externally_attributed_conversions
// to learn more about importing externally attributed conversions.


// $feed->setExternalAttributionModel('Linear');
// $feed->setExternalAttributionCredit(0.3);


$offlineConversionOperation
= new OfflineConversionFeedOperation();
$offlineConversionOperation
->setOperator(Operator::ADD);
$offlineConversionOperation
->setOperand($feed);
$offlineConversionOperations
= [$offlineConversionOperation];


$result
= $offlineConversionService->mutate($offlineConversionOperations);


$feed
= $result->getValue()[0];
printf
(
   
"Uploaded offline conversion value of %d for Google Click ID = '%s' to '%s'.\n",
    $feed
->getConversionValue(),
    $feed
->getGoogleClickId(),
    $feed
->getConversionName()
);


What problem I have now:

1. I couldn't understand how to use above code snippet.Full implementation.
2. I couldn't find the way of linking this to my adword account. Where could i add the credentials that will link the API to my account.

Can anyone point me to the right direction? Any code snippet, explanation or supporting links would be helpful.

Thanks in advance,
Navin


Dhanya Sundararaju (AdWords API Team)

unread,
Dec 28, 2018, 3:31:11 PM12/28/18
to AdWords API and Google Ads API Forum
Hi Navin,

Please find my responses inline below:
  1. I couldn't understand how to use above code snippet.Full implementation.
  1. You can run the UploadOfflineConversions.php file from the php client library you installed. You will need to specify your GCLID details in the declared const in your program. This should upload the offline clicks to your account.
  1. I couldn't find the way of linking this to my adword account. Where could i add the credentials that will link the API to my account.
  1. Your client customer id is read from adsapi_php.ini file. Please follow the steps mentioned in the README.md file for complete setup including logging.
Let me know if you have any further questions.

Regards,
Dhanya, AdWords API Team
Reply all
Reply to author
Forward
0 new messages