Get started

Learn how to let your customers quickly and easily purchase a domain with Google Domains right from your website. This document will show you how to add a Google Domains Express Checkout hyperlink to your site or how to use the JavaScript API to provide a more customized experience for your customers.

Express Checkout hyperlinks are specially-formatted URLs that you use on your site to direct customers to Google Domains for a fast and simplified checkout flow. While Express Checkout hyperlinks do not provide the same level of customization as the JavaScript API (described below), they are very simple to use.

There are 4 types of Express Checkout hyperlinks you can create:

 https://domains.google.com/express

This hyperlink will send a user to the Express Checkout flow, where they may search for and buy a domain name with just a few clicks.

  https://domains.google.com/express?s=search_query

This hyperlink will send a user to the Express Checkout flow, where they will see search results for the query search_query. They may then purchase the domain using the Express Checkout flow.

 https://domains.google.com/express?s=search_query&tldFilter=com

This hyperlink will send a user to the Express Checkout flow, where they will see search results for the query search_query and for the top-level domain com. They may then purchase a domain from the search results using the Express Checkout flow.

 https://domains.google.com/express?d=search_query.com

This hyperlink will send a user directly to the Express Checkout cart with the provided domain (search_query.com in this example) as the only item in the cart. If the provided domain name is not available for purchase the user will receive a warning message.

Express Checkout JavaScript API

Use the JavaScript API if you need more fine-grained control of a user's experience when purchasing a domain from Google. Examples of more fine-grained control include redirecting back to your site after a purchase, or automatically configuring a user's DNS records after a purchase but before redirecting back to your site.

Follow the steps below to use the Express Checkout JavaScript API on your site:

1. Set up your account

Contact Google Domains to apply to be a partner. Once approved, we set up a new account that you need to configure. When you configure your account, you set a template which determines the behavior of domains registered through the Express Checkout API. This template includes the following:

  • Resource records that you'd like automatically added to new domains. For example, you can set A, AAAA, CNAME, and MX, records to have your web service automatically configured by default.
  • The domain you want to use the Express Checkout API on. You may also choose to include subdomains.
  • Any relevant fields you want to pass to Domains.

2. Import the API source

Add the following script source to the head element of your website document:

<script src="https://apis.google.com/js/api.js"></script>

3. Option 1: Invoke the API

To invoke the Express flow on page load, add the following JavaScript skeleton to the head element of your website document:

    <script type="javascript">
    gapi.load('domains', function() {
        gapi.domains.searchAndBuy(
        {
            partnerId: /*RQ*/,
            successUrl: /*RQ*/,
            cancelUrl: /*RQ*/,
            defaultQuery: /*Opt*/,
            defaultTlds: /*Opt*/,
            template: { /*RQ if using multiple templates*/
                templateId: /*RQ*/,
                vars: {
                    /*Opt*/
                },
            }
        });
    });
    </script>

4. Option 2: Create a wrapper function

To invoke the Express flow via a function, add the following JavaScript to the head element of your page:

    function showGoogleDomainsFlow() { /*Defined function*/
        gapi.load('domains', function() {
            gapi.domains.searchAndBuy({
                ....
            });
        });
    }

5. Invoke the function

Add this button to invoke the function that you created:

    <button onclick="showGoogleDomainsFlow()">Buy a domain </button>

The end result should look like the following:

    <head>
        <script src="https://apis.google.com/js/api.js"></script>
        <script type="javscript">
        function showGoogleDomainsFlow() {
            gapi.load('domains', function() {
                gapi.domains.searchAndBuy({
                    ....
                });
            });
        }
        </script>
        ....
    </head>

    <body>
        ....
        <button onclick="showGoogleDomainsFlow()">Buy a domain</button>
        ....
    </body>