1.0.5 • Published 3 days ago

google-pax-sdk v1.0.5

Weekly downloads
-
License
-
Repository
github
Last release
3 days ago

Partner Ads Experience (PAX) API

This Repository contains all of the interfaces needed to integrate with Google Partner Ads experience.

This SDK is required when you develop your app with Typescript. For javascript developer, this SDK is not required as part of your app library. But it is also useful to check the type declaration files during integration developing process.

Directory/fileDescription
sdk/integrator.d.tsThe Ads app integrator entry point
sdk/configConfiguration required by the Ads app to launch the partner ads experience
sdk/required_services.d.tsWrapper interface for all the communication required services
sdk/servicesAll service interfaces required to communicate between the partner app and the Ads app
sdk/services/adsServices provided by the Ads app and called by the partner
sdk/services/partnerServices provided by the partner and called by the Ads app

Quick start

Note: The following code assumes that you develop with Javascript.

Config setup

let paxConfig = {
  authAccess: {
    oauthTokenAccess: {
      token: ${token},
    }
  },
  locale: ${locale},
  clientConfig: {
    contentContainer: ${ads_container_element_id},
  },
};

To add debugging config, set:

let paxConfig = {
  authAccess: {
    oauthTokenAccess: {
      token: ${token},
    }
  },
  locale: ${locale},
  clientConfig: {
    contentContainer: ${ads_container_element_id},
  },
  debuggingConfig: {
    env: 'QA_PROD'
  },
};

To add content config, set:

let paxConfig = {
  authAccess: {
    oauthTokenAccess: {
      token: ${token},
    }
  },
  locale: ${locale},
  clientConfig: {
    contentContainer: ${ads_container_element_id},
  },
  debuggingConfig: {
    env: 'QA_PROD'
  },
  contentConfig: {
    partnerAdsExperienceConfig: {
      reportingStyle: 'REPORTING_STYLE_FULL'
    },
  },
};

Ads required services setup

Ads required services play the key role to communicate between the Ads app and the partner app during the Ads app running time.

OAuth data

let authInfoService = {
  get: ${get_access_info_impl},
  fix: ${fix_access_info_impl},
};

Conversion tracking

let conversionTrackingService = {
  getSupportedConversionLabels: ${get_supported_conversion_labels_impl},
  getPageViewConversionSetting: ${get_page_view_conversion_setting_impl},
  getSupportedConversionTrackingTypes:
  ${get_supported_conversion_tracking_types_impl},
};

Business info

let businessService = {
  getBusinessInfo: ${get_business_info_impl},
  fixBusinessInfo: ${fix_business_info_impl},
};

Terms and conditions

let termsAndConditionsService = {
  notify: ${notify_impl},
};

Account status

let accountStatusService = {
  disconnect: ${disconnect_impl},
};

Campaign service

let campaignService = {
  notifyNewCampaignCreated: ${notify_impl},
};

Partner date range service

let partnerDateRangeService = {
  get: ${get_date_range_impl},
};

Wrap all Ads app required services

let paxServices = {
  authenticationService: authInfoService,
  businessService: businessService,
  conversionTrackingService: conversionTrackingService,
  termsAndConditionsService: termsAndConditionsService,
  accountStatusService: accountStatusService,
  campaignService: campaignService,
  partnerDateRangeService: partnerDateRangeService,
};

Launch with the integrator

// Insert the script with integrator js file from Google gstatic.com.
let sc = document.createElement('script');
sc.src = 'https://www.gstatic.com/pax/${version}/pax_integrator.js';
document.body.append(sc);

// Create an element to launch the Ads app.
let rootContainer = document.getElementById(${root_element_id});
let adsContainer = document.createElement('div');
adsContainer.id = ${ads_container_element_id};
rootContainer.appendChild(adsContainer);

// Call launch api
google.ads.integration.integrator.launchGoogleAds(paxConfig, paxServices);

Get services supported by the Ads app

const adsAppHandler = await google.ads.integration.integrator.launchGoogleAds(paxConfig, paxServices);
const adsSupportedServices = adsAppHandler.getServices();

Get conversion tracking id from the Ads app

const ctService = adsSupportedServices.conversionTrackingService;
const conversionTrackingId = (await ctService.getConversionTrackingId(${get_conversion_tracking_id_request})).conversionTrackingId;

Get terms and conditions state from the Ads app

const accountService = adsSupportedServices.accountService;
const termsAndServicesIsAccepted = (await
accountService.getTermsAndConditionsState(${get_terms_and_conditions_state_request})).isAccepted;

Get account id from the Ads app

const accountService = adsSupportedServices.accountService;
const customerId = (await
accountService.getAccountId(${get_account_id_request})).customerId;
const externalCustomerId =  (await
accountService.getAccountId(${get_account_id_request})).externalCustomerId;
const formattedExternalCustomerId = (await
accountService.getAccountId(${get_account_id_request})).formattedExternalCustomerId;

Notify PAX about the updated date range

const adsDateRangeService = adsSupportedServices.adsDateRangeService;
const updatedDateRangeService = (await
adsDateRangeService.update(${update_selected_date_range_request}));

Disconnect the Ads app

const accountService = adsSupportedServices.accountService;
const disconnectIsSuccess = (await
accountService.disconnect(${disconnect_request})).isSuccess;

Contributing guidelines

Currently the GitHub repository is owned by Google Partner Ads Experience dev team. If you find any bugs, please report to: Google group.

Other resources

  • TBD: to be published

License

Copyright 2023 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
1.0.7

3 days ago

1.0.5

11 days ago

1.0.4

16 days ago

1.0.2

18 days ago

1.0.1

19 days ago

1.0.0

1 month ago

0.2.9

2 months ago

0.2.8

3 months ago

0.2.7

3 months ago

0.2.6

4 months ago

0.2.5

6 months ago

0.2.3

9 months ago

0.2.4

9 months ago

0.2.2

9 months ago

0.2.1

10 months ago

0.2.0

10 months ago

0.1.0

11 months ago

0.0.1

11 months ago