How to implement Universal Search Library

Updating extension files

  1. Make sure you have the following information on hand:
    • background.bundle.js file (provided by your Adgoal manager)
    • content.bundle.js file (provided by your Adgoal manager)
    • Your Adgoal credentials API key, member hash, and panel hash (Where do I find my Adgoal credentials?)
  1. Copy two files (background.bundle.js and content.bundle.js) to the root directory of your extension folder.
  2. Go to your manifest.json file to check whether you already have a “background” section. Get the name of your file (usually called background.js) or create one.

mceclip0.png

Example for Manifest V2 in manifest.json file

mceclip2.png

Example for Manifest V3 in manifest.json file

mceclip3.png

  1. Add the following lines of code to the top of your background file (before all existing code, if there is any), replacing api_key, member_hash, and panel_hash with your Adgoal credentials:

Example for Manifest V2 in background file

const universalSearchCredentials = {
API_PUBLIC_KEY: 'api_key',
MEMBER_HASH: 'member_hash',
PANEL_HASH: 'panel_hash'
}

Example for Manifest V3 in background file

importScripts(chrome.runtime.getURL('./background.bundle.js'));
const universalSearchCredentials = {
API_PUBLIC_KEY: 'api_key',
MEMBER_HASH: 'member_hash',
PANEL_HASH: 'panel_hash'
}
  1. Add the resulting background file to your extension folder.

mceclip5.png

Updating manifest.json

Updating your manifest.json file is mainly required for requesting the necessary permissions from Google. If you skip this step, Universal Search won’t be able to gather the data it needs from Google, and the library won’t work.

  1. Go to your manifest.json file to check whether you already have a content_scripts section. If there is no such section, create one.
    • Add https://*/* to the matches group. If you already have an <all_urls> setting instead, it will also work for the library. Otherwise, we suggest stating https://*/*
    • Add content.bundle.js to the js group. If you already have a line of code with your own script in this group, do not replace it with content.bundle.js — keep both lines.

This section of your manifest code should now look like this:

   "content_scripts": [
{
"matches": [
"https://*/*"
],
"js": [
"your-script.js",
"content.bundle.js"
]
}
],

If your content_scripts section has a "run_at": "document_start" parameter, remove it or set it at "document_end" for the library script to work correctly.

  1. This step is for Manifest V2 only.

Add background.bundle.js to the scripts group in the background section of your manifest.json file.

This section of your manifest code should now look like this:

   "background": {
"scripts": [
"background.bundle.js",
"background.js"
]
},
  1. Add the following permissions required for Universal Search to your manifest.json file:

Permissions list for Manifest V2

   "permissions": [
"storage",
"https://*/*"
]

Permissions list for Manifest V3

   "permissions": [
"storage"
],
"host_permissions": [
"https://*/*"
]

You can double-check your manifest.json code using the example below.

Resulting code example manifest.json

Example for Manifest V2
{
"name": "your_name",
"description": "your_description",
"version": "your_version",
"manifest_version": 2,
"content_scripts": [
{
"matches": [
"https://*/*"
],
"js": [
"your-script.js",
"content.bundle.js"
]
}
],
"background": {
"scripts": [
"background.bundle.js",
"background.js"
]
},
"permissions": [
"storage",
"https://*/*"
]
}

Example for Manifest V3

{
"name": "your_name",
"description": "your_description",
"version": "your_version",
"manifest_version": 2,
"content_scripts": [
{
"matches": [
"https://*/*"
],
"js": [
"your-script.js",
"content.bundle.js"
]
}
],
"background": {
"service_worker": [
"background.js"
]
},
"permissions": [
"storage",
],
"host_permissions": [
"https://*/*"
]
}

Testing

After completing all implementation steps, go to the browser you usually use and test that everything works correctly. Enter a search query in Google, Bing, Yahoo, or Yandex. Some of the search results should be highlighted with logos like this:

mceclip0.png

Let your Adgoal manager know that you successfully completed the library installation. If your extension is distributed via Google Web Store, you might also need to provide a rationale for new permissions.

If the search results look the same as before, double-check that you are entering a query in one of the supported search engines and haven’t skipped any of the implementation steps. If nothing helps, contact your Adgoal manager.

Updating your privacy policy

In order to stay compliant with privacy regulations, you should add the following paragraph to your privacy policy, preferably as one of the final statements:

Our extension is in a partnership with Adgoal (https://adgoal.de/) and contains their Adgoal script meant for link affiliation. We can receive a reward for sales that happen after users click on the affiliate links. You can learn more about the process in Adgoal’s privacy policy at https://www.adgoal.de/en/privacy.html. The ads associated with this partnership do not interfere with any third-party website, in-app, or native advertising in any way.