এই কুইকস্টার্টে, আপনি Google Marketing Platform Admin API-এর কাছে অনুরোধ তৈরি করেন এবং নির্দিষ্ট Google Marketing Platform সংস্থার সাথে লিঙ্ক করা Google Analytics অ্যাকাউন্টগুলির তালিকা সম্বলিত প্রতিক্রিয়াগুলি দেখেন।
আপনি আপনার স্থানীয় পরিবেশে একটি প্রোগ্রামিং ভাষা SDK ব্যবহার করে বা REST API ব্যবহার করে এই দ্রুত শুরু করতে পারেন।
পূর্বশর্ত
এই কুইকস্টার্টটি সম্পূর্ণ করার জন্য আপনার প্রয়োজন:
- একটি Google ক্লাউড প্রকল্প সেট আপ করুন এবং Google Marketing Platform Admin API সক্ষম করুন৷
- আপনার স্থানীয় মেশিনে:
- Google ক্লাউডের সাথে ইনস্টল করুন, শুরু করুন এবং প্রমাণীকরণ করুন৷
- আপনার ভাষার জন্য SDK ইনস্টল করুন
একটি Google ক্লাউড প্রকল্প সেট আপ করুন৷
আপনার Google ক্লাউড প্রকল্প সেট আপ করুন এবং Google Marketing Platform Admin API সক্ষম করুন৷
একটি নতুন Google ক্লাউড প্রকল্প নির্বাচন বা তৈরি করতে এবং স্বয়ংক্রিয়ভাবে Google Marketing Platform Admin API সক্ষম করতে এই বোতামটি ক্লিক করুন:
Google Marketing Platform Admin API সক্ষম করুন৷Google ক্লাউড সেট আপ করুন
আপনার স্থানীয় মেশিনে, সেট আপ করুন এবং Google ক্লাউড দিয়ে প্রমাণীকরণ করুন৷
Google ক্লাউড ইনস্টল এবং আরম্ভ করুন ।
আপনি যদি আগে Google ক্লাউড ইনস্টল করে থাকেন, তাহলে এই কমান্ডটি চালিয়ে আপনার
gcloud
উপাদান আপডেট করা হয়েছে তা নিশ্চিত করুন।gcloud components update
Google ক্লাউডের সাথে প্রমাণীকরণ করতে, এই কমান্ডটি চালিয়ে একটি স্থানীয় অ্যাপ্লিকেশন ডিফল্ট শংসাপত্র (ADC) ফাইল তৈরি করুন৷ কমান্ড দ্বারা চালু করা ওয়েব ফ্লো আপনার ব্যবহারকারীর শংসাপত্র প্রদান করতে ব্যবহৃত হয়।
gcloud auth application-default login --scopes="https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/marketingplatformadmin.analytics.read"
লক্ষ্য করুন কিভাবে Google Marketing Platform Admin API-এর প্রয়োজনীয় স্কোপ কমান্ডে নির্দিষ্ট করা হয়েছে।
আরও তথ্যের জন্য, অ্যাপ্লিকেশন ডিফল্ট শংসাপত্র সেট আপ দেখুন।
Google Marketing Platform Admin API-এর জন্য একটি কোটা প্রকল্প প্রয়োজন, যা ডিফল্টরূপে সেট করা হয় না। আপনার কোটা প্রকল্প কিভাবে সেট করবেন তা জানতে, ব্যবহারকারীর শংসাপত্র নির্দেশিকা দেখুন।
আপনার Google মার্কেটিং প্ল্যাটফর্ম প্রতিষ্ঠানের আইডি শনাক্ত করুন
Google Marketing Platform Admin API ব্যবহার করার জন্য, আপনাকে আপনার Google Marketing Platform প্রতিষ্ঠানের ID সনাক্ত করতে হবে। গুগল মার্কেটিং প্ল্যাটফর্মে লগইন করুন, অ্যাডমিনিস্ট্রেশন ডায়ালগে যান, আপনার প্রতিষ্ঠান নির্বাচন করুন এবং প্রতিষ্ঠানের বিবরণের অধীনে প্রতিষ্ঠান আইডি নোট করুন।
Google Marketing Platform Admin API-এর সমস্ত অনুরোধে অবশ্যই প্রতিষ্ঠানের ID organizations/ORGANIZATION_ID
ফরম্যাটে অন্তর্ভুক্ত করতে হবে।
আপনার প্রোগ্রামিং ভাষার জন্য SDK সেট আপ করুন
আপনার স্থানীয় মেশিনে, আপনার প্রোগ্রামিং ভাষার জন্য SDK ইনস্টল করতে নিম্নলিখিত ট্যাবগুলির একটিতে ক্লিক করুন।
জাভা
পিএইচপি
পাইথন
Node.js
.নেট
রুবি
বিশ্রাম
নিম্নলিখিত প্রবেশ করে আপনার পরিবেশ ভেরিয়েবল কনফিগার করুন.
- আপনার Google মার্কেটিং প্ল্যাটফর্ম সংস্থার ID দিয়ে
ORGANIZATION_ID
প্রতিস্থাপন করুন। - আপনার Google ক্লাউড প্রকল্পের ID দিয়ে
PROJECT_ID
প্রতিস্থাপন করুন।
একটি API কল করুন
এখন আপনি Google মার্কেটিং প্ল্যাটফর্ম API ব্যবহার করে নির্দিষ্ট Google মার্কেটিং প্ল্যাটফর্ম সংস্থার সাথে Google Analytics অ্যাকাউন্টের লিঙ্ক তালিকাভুক্ত করতে পারেন। API-তে আপনার প্রথম কল করতে নিম্নলিখিত কোডটি চালান:
জাভা
কুইকস্টার্ট চালানোর সময় .setPageSize
এবং .setPageToken
এ কলগুলি সরান৷
import com.google.ads.marketingplatform.admin.v1alpha.AnalyticsAccountLink; import com.google.ads.marketingplatform.admin.v1alpha.ListAnalyticsAccountLinksRequest; import com.google.ads.marketingplatform.admin.v1alpha.MarketingplatformAdminServiceClient; import com.google.ads.marketingplatform.admin.v1alpha.OrganizationName; public class SyncListAnalyticsAccountLinks { public static void main(String[] args) throws Exception { syncListAnalyticsAccountLinks(); } public static void syncListAnalyticsAccountLinks() throws Exception { // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (MarketingplatformAdminServiceClient marketingplatformAdminServiceClient = MarketingplatformAdminServiceClient.create()) { ListAnalyticsAccountLinksRequest request = ListAnalyticsAccountLinksRequest.newBuilder() .setParent(OrganizationName.of("[ORGANIZATION]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); for (AnalyticsAccountLink element : marketingplatformAdminServiceClient.listAnalyticsAccountLinks(request).iterateAll()) { // doThingsWith(element); } } } }
পিএইচপি
use Google\Ads\MarketingPlatform\Admin\V1alpha\AnalyticsAccountLink; use Google\Ads\MarketingPlatform\Admin\V1alpha\Client\MarketingplatformAdminServiceClient; use Google\Ads\MarketingPlatform\Admin\V1alpha\ListAnalyticsAccountLinksRequest; use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; /** * Lists the Google Analytics accounts link to the specified Google Marketing * Platform organization. * * @param string $formattedParent The parent organization, which owns this collection of Analytics * account links. Format: organizations/{org_id} * Please see {@see MarketingplatformAdminServiceClient::organizationName()} for help formatting this field. */ function list_analytics_account_links_sample(string $formattedParent): void { // Create a client. $marketingplatformAdminServiceClient = new MarketingplatformAdminServiceClient(); // Prepare the request message. $request = (new ListAnalyticsAccountLinksRequest()) ->setParent($formattedParent); // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ $response = $marketingplatformAdminServiceClient->listAnalyticsAccountLinks($request); /** @var AnalyticsAccountLink $element */ foreach ($response as $element) { printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); } } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); } } /** * Helper to execute the sample. * * This sample has been automatically generated and should be regarded as a code * template only. It will require modifications to work: * - It may require correct/in-range values for request initialization. * - It may require specifying regional endpoints when creating the service client, * please see the apiEndpoint client configuration option for more details. */ function callSample(): void { $formattedParent = MarketingplatformAdminServiceClient::organizationName('[ORGANIZATION]'); list_analytics_account_links_sample($formattedParent); }
পাইথন
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.ads import marketingplatform_admin_v1alpha def sample_list_analytics_account_links(): # Create a client client = marketingplatform_admin_v1alpha.MarketingplatformAdminServiceClient() # Initialize request argument(s) request = marketingplatform_admin_v1alpha.ListAnalyticsAccountLinksRequest( parent="parent_value", ) # Make the request page_result = client.list_analytics_account_links(request=request) # Handle the response for response in page_result: print(response)
Node.js
ব্যবহার: node packages/google-marketingplatform-admin/samples/quickstart.js সংগঠন/ORGANIZATION_ID।
/** * This snippet has been automatically generated and should be regarded as a code template only. * It will require modifications to work. * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** * Required. The parent organization, which owns this collection of Analytics * account links. Format: organizations/{org_id} */ // const parent = 'abc123' /** * Optional. The maximum number of Analytics account links to return in one * call. The service may return fewer than this value. * If unspecified, at most 50 Analytics account links will be returned. The * maximum value is 1000; values above 1000 will be coerced to 1000. */ // const pageSize = 1234 /** * Optional. A page token, received from a previous ListAnalyticsAccountLinks * call. Provide this to retrieve the subsequent page. * When paginating, all other parameters provided to * `ListAnalyticsAccountLinks` must match the call that provided the page * token. */ // const pageToken = 'abc123' // Imports the Admin library const {MarketingplatformAdminServiceClient} = require('@google-ads/marketing-platform-admin').v1alpha; // Instantiates a client const adminClient = new MarketingplatformAdminServiceClient({fallback: true}); async function callListAnalyticsAccountLinks() { // Construct request const request = { parent, }; // Run request const iterable = adminClient.listAnalyticsAccountLinksAsync(request); for await (const response of iterable) { console.log(response); } } callListAnalyticsAccountLinks();
.নেট
using Google.Ads.MarketingPlatform.Admin.V1Alpha; using Google.Api.Gax; using System; public sealed partial class GeneratedMarketingplatformAdminServiceClientSnippets { /// <summary>Snippet for ListAnalyticsAccountLinks</summary> /// <remarks> /// This snippet has been automatically generated and should be regarded as a code template only. /// It will require modifications to work: /// - It may require correct/in-range values for request initialization. /// - It may require specifying regional endpoints when creating the service client as shown in /// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint. /// </remarks> public void ListAnalyticsAccountLinks() { // Create client MarketingplatformAdminServiceClient marketingplatformAdminServiceClient = MarketingplatformAdminServiceClient.Create(); // Initialize request argument(s) string parent = "organizations/[ORGANIZATION]"; // Make the request PagedEnumerable<ListAnalyticsAccountLinksResponse, AnalyticsAccountLink> response = marketingplatformAdminServiceClient.ListAnalyticsAccountLinks(parent); // Iterate over all response items, lazily performing RPCs as required foreach (AnalyticsAccountLink item in response) { // Do something with each item Console.WriteLine(item); } // Or iterate over pages (of server-defined size), performing one RPC per page foreach (ListAnalyticsAccountLinksResponse page in response.AsRawResponses()) { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (AnalyticsAccountLink item in page) { // Do something with each item Console.WriteLine(item); } } // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required int pageSize = 10; Page<AnalyticsAccountLink> singlePage = response.ReadPage(pageSize); // Do something with the page of items Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); foreach (AnalyticsAccountLink item in singlePage) { // Do something with each item Console.WriteLine(item); } // Store the pageToken, for when the next page is required. string nextPageToken = singlePage.NextPageToken; } }
বিশ্রাম
এই অনুরোধ পাঠাতে, কমান্ড লাইন থেকে curl কমান্ড চালান বা আপনার অ্যাপ্লিকেশনে REST কল অন্তর্ভুক্ত করুন।
curl -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \\ -H "x-goog-user-project: ${PROJECT_ID}" -H "Content-Type: application/json" \\ https://marketingplatformadmin.googleapis.com/v1alpha/organizations/${ORGANIZATION_ID}/analyticsAccountLinks
নমুনা কোড নির্দিষ্ট Google মার্কেটিং প্ল্যাটফর্ম সংস্থার সাথে লিঙ্ক করা Google Analytics অ্যাকাউন্টগুলির একটি তালিকা সহ একটি প্রতিক্রিয়া প্রিন্ট করে:
{
"analyticsAccountLinks": [
{
"name": "organizations/0a123456789-wxyz/analyticsAccountLinks/1234567890",
"analyticsAccount": "analyticsadmin.googleapis.com/accounts/1234567890",
"displayName": "Demo Account",
"linkVerificationState": "LINK_VERIFICATION_STATE_VERIFIED"
}
]
}
অভিনন্দন! আপনি Google Marketing Platform API-এ আপনার প্রথম অনুরোধ পাঠিয়েছেন।