Skip to content

Commit

Permalink
add Knowledge Graph API
Browse files Browse the repository at this point in the history
  • Loading branch information
ziodave committed Jan 4, 2024
1 parent f45ae4f commit 875abb7
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 1 deletion.
83 changes: 83 additions & 0 deletions docs/knowledge-graph/analytics-api-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
sidebar_position: 10
toc_min_heading_level: 2
toc_max_heading_level: 5
---

# Analytics API Guide

## Introduction

To import analytics data, use the Analytics API, following these steps:

1. Connect the Google Search Console to your Knowledge Graph (Botify is also supported as an alternative to Google Search Console, [inquire with us](https://wordlift.io/contact-us/)).
1. Run the Analytics Import.

## Authorization

:::info

Using the Analytics API requires a WordLift Key. If you're unsure which one is the WordLift Key for an account, go to [my.wordlift.io](https://my.wordlift.io) and scroll through the list of websites.

:::

## Connect Google Search Console

In order to connect the Google Search Console to your Knowledge Graph, a client needs to perform an interactive authentication and authorization process with Google by using a Web Browser.

### Build Authorization URL

The process starts using a specially crafted URL. To get the URL use the "Build Authorization URI" API (replace `<key>` with your WordLift Key):

```sh
curl -X "POST" "https://api.wordlift.io/google-search-console/oauth2/build-authorize-uri" \
-H 'Authorization: Key <key>' \
-H 'Content-Type: application/json; charset=utf-8' \
-d $'{
"redirect_uri": "https://developers.google.com/oauthplayground"
}'
```

:::warning

The `redirect_uri` must be set to `https://developers.google.com/oauthplayground`.

:::

This will yield the following response:

```json
{
"authorize_uri": "https://accounts.google.com/o/oauth2/v2/auth?redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground%2F&prompt=consent&response_type=code&client_id=615875160260-bsbm4u5fb2hrke3ln89n33v8rmmksth9.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fwebmasters.readonly&access_type=offline"
}
```

Open the above URL in a Web Browser.

### Authenticate and Authorize with Google

When requested provide your Google e-mail address. The account must be able to access the Google Search Console for the target account:

![Authenticate with Google, by providing your email address](./images/authenticate-with-google.png)

Then provide the password and complete authentication:

![Authenticate with Google, by providing your password](./images/authenticate-with-google.png)

If requested, provide a 2-Step Verification code:

![Authenticate with Google, by providing a 2-Step Verification code](./images/authenticate-with-google.png)

Then finally click "Allow" to authorize the Analytics API to access the Google Search Console data:

![Authorize with Google](./images/authorize-with-google.png)

After clicking "Allow", the browser is redirected to a URL like this:

```
https://developers.google.com/oauthplayground/?code=<authorization-code>&scope=https://www.googleapis.com/auth/webmasters.readonly
```

Copy the value in `code=<authorization-code>` (the `<authorization-code>` part) to use it with the Exchange Authorization Code API.

###
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ const config = {
label: "Products",
position: "left",
items: [
{
label: "Knowledge Graph",
to: "knowledge-graph/analytics-api-guide",
},
{
label: "WordPress Plugin",
to: "wordpress-plugin",
Expand All @@ -96,7 +100,7 @@ const config = {
label: "Product Knowledge Graph Builder",
to: "product-knowledge-graph-builder/introduction",
},
{
{
label: "Cloud",
to: "cloud",
},
Expand Down

0 comments on commit 875abb7

Please sign in to comment.