لینک مستقیم

شما می‌توانید هرگونه پیاده‌سازی از Community Connector خود را با یک لینک به اشتراک بگذارید. وقتی کاربری لینک را دنبال می‌کند، مستقیماً به Looker Studio با کانکتور انتخاب شده شما منتقل می‌شود.

برای دریافت لینک مستقیم برای رابط انجمن خود، این مراحل را دنبال کنید:

  1. به Apps Scripts بروید و پروژه‌ی Community Connector را برای اشتراک‌گذاری باز کنید. روی Deploy > Manage Deployments کلیک کنید.
  2. برای اشتراک‌گذاری، روی Active deployment کلیک کنید. در زیر Looker Studio Add-on URL ، یک لینک مستقیم به Looker Studio برای deployment انتخاب شده نمایش داده می‌شود، روی Copy کلیک کنید. روش دیگر، در زیر Deployment ID روی Copy کلیک کنید و Deployment ID کپی شده را به URL زیر اضافه کنید تا یک لینک مستقیم ایجاد شود:
    https://lookerstudio.google.com/datasources/create?connectorId=DEPLOYMENT_ID
  3. The direct link can be shared with users. For example, send it via email, post it on a website, blog, social media, etc.

If you know the configuration values that your users will want ahead of time, you can provide additional query parameters to pre-populate the connector configuration. The pre-populated configuration can still be modified by users.

To create a preconfigured direct link, add the following optional query parameters:

  • connectorConfig - A URL encoded JSON string containing key-value pairs to use to pre-populate the connector configuration.

    • Key names must match the parameter names defined in the connector config.
    • TEXTINPUT, TEXTAREA, and SELECT_SINGLE values should be strings.
    • CHECKBOX values should be a boolean.
    • SELECT_MULTIPLE values should be an array of strings.
  • reportTemplateId - An identifier for the default reporting template to use for the connector. If a default template is set in the connector manifest, this value will override the manifest. See How To Add The Report Template for the value to use.

Example

The following example illustrates how to create a direct link to the StackOverflow Questions community connector. The direct link pre-populates the connector configuration to use the looker-studio tag on Stack Overflow.

Step 1: Create the config JSON

The keys for the config JSON are the names of each configuration item. For the Stack Overflow config, these names are tagged, pagesize, and sort.

JSON before encoding

{
    "tagged": "looker-studio",
    "pagesize": 25,
    "sort": "activity"
}

مرحله ۲: رمزگذاری URL

پس از ایجاد JSON پیکربندی، URL شیء را کدگذاری می‌کند. یک گزینه آسان استفاده از تابع جاوا اسکریپت encodeURIComponent است.

رمزگذاری آدرس اینترنتی

// get a reference to the jsonConfig
var jsonConfig;
var encoded = encodeURIComponent(jsonConfig);

نتیجه، رشته کدگذاری شده زیر است:

"%7B%22tagged%22%3A%22looker-studio%22%2C%22pagesize%22%3A%2225%22%2C%22sort%22%3A%22activity%22%7D"

مرحله ۳: ساخت URL

کد زیر لینک مستقیم را می‌سازد. توجه داشته باشید که برای ساخت URL به Deployment ID کانکتور خود نیاز دارید.

data-studio/links.gs
// These variables should be filled in as necessary for your connector.
let configJSON;
let templateId;
let deploymentId;

const params = [];

const jsonString = JSON.stringify(configJSON);
const encoded = encodeURIComponent(jsonString);
params.push(`connectorConfig=${encoded}`);

params.push(`reportTemplateId=${templateId}`);

params.push(`connectorId=${deploymentId}`);

const joinedParams = params.join("&");
const URL = `https://datastudio.google.com/datasources/create?${joinedParams}`;

این، URL کدگذاری شده زیر را برمی‌گرداند، یک لینک مستقیم از پیش پر شده برای رابط:

https://lookerstudio.google.com/datasources/create?connectorConfig=%7B%22tagged%22%3A%22looker-studio%22%2C%22pagesize%22%3A%2225%22%2C%22sort%22%3A%22activity%22%7D&reportTemplateId=1lR9CGfx3uyQp6oz7oAgA1rsqZViA-IQs&connectorId=AKfycbwGMj-oe532y-NEbMHo-KLUCEz0EEGOZj-3lhEgw7q65-hs-T_F9B3Qjw