How to configure the work of your advertising network with Google Search translation functions for your Google website

How to configure the work of your advertising network with Google Search translation functions for your Google website

Google Search provides several functions related to the translation that allow users to access the translated content. If your advertising network does not work properly on the translated web pages, you need to follow the recommendations given in this manual so that your ads are correctly displayed and attributes are correctly attached.

Our approach to working with translations for your site in Google

When users turn to the translated content provided by Google Translate from search results, Google receives a page from the publisher, changes the source URL and translates the web page after the user clicked to the translated result.

How to transform the URL Google Translate into an original URL for your Google website

If your advertising network depends on the initial URL publisher, you need to convert the URL Google Translate so that the ads are displayed correctly. Follow these steps to decode the name of the publisher host:

  • Eliminate the prefix of the domain from the name of the host, deleting the suffix .translate.goog.
  • Divide the _x_tr_enc parameter using a comma (,) and save them as encoding_list.
  • Add the parameter _x_tr_hp to the prefix of the domain, if it exists.
  • If Encoding_List contains 1 and the output begins with 1-, delete the prefix 1- from the step result 2.
  • If Encoding_List contains 0 and the conclusion begins with 0-, delete the prefix 0- from the result of step 3. If the prefix was removed, install is_idn in True, otherwise install it in FALSE.
  • Replace / b- b / (regular expression) with a point (.) In a line.
  • Replace the double dash (-) with a single dash (-).
  • If IS_idn is installed in True, add the prefix punycode xn--.
  • Optional: transform into Unicode.

An example of a JavaScript code for decoding a host name from the URL Google Translate

function decodeHostname(proxyUrl) {
 const parsedProxyUrl = new URL(proxyUrl);
 const fullHost = parsedProxyUrl.hostname;
 // 1. Извлеките префикс домена из имени хоста, удалив суффикс ".translate.goog"
 let domainPrefix = fullHost.substring(0, fullHost.indexOf('.'));
 // 2. Разделите параметр _x_tr_enc на части, используя запятую, и сохраните как encodingList
 const encodingList = parsedProxyUrl.searchParams.has('_x_tr_enc') ?
 parsedProxyUrl.searchParams.get('_x_tr_enc').split(',') : [];
 // 3. Добавьте значение параметра _x_tr_hp к префиксу домена, если оно существует
 if (parsedProxyUrl.searchParams.has('_x_tr_hp')) {
 domainPrefix = parsedProxyUrl.searchParams.get('_x_tr_hp') + domainPrefix;
 }
 // 4. Удалите префикс '1-' из результата шага 2, если encodingList содержит '1' и результат начинается с '1-'.
 if (encodingList.includes('1') && domainPrefix.startsWith('1-')) {
 domainPrefix = domainPrefix.substring(2);
 }
 // 5. Удалите префикс '0-' из результата шага 3, если encodingList содержит '0' и результат начинается с '0-'.
 // Установите isIdn в true, если префикс был удален, в false в противном случае.
 let isIdn = false;
 if (encodingList.includes('0') && domainPrefix.startsWith('0-')) {
 isIdn = true;
 domainPrefix = domainPrefix.substring(2);
 }
 // 6. Замените /-/ на точку (.)
 // 7. Замените двойное тире на одно тире.
 let decodedSegment = domainPrefix.replaceAll(/-/g, '.').replaceAll('--', '-');
 // 8. Если isIdn равно true, добавьте префикс 'xn--'.
 if (isIdn) {
 decodedSegment = 'xn--' + decodedSegment;
 }
 return decodedSegment;
}

How to restore the original URL for your site in Google

  • Using the original URL page, replace the host name with a decoded host name.
  • Remove all parameters _x_tr_*.

How to test your code on your Google website

You can create unit tests for your code using the next table. When submitting Proxyurl, the Decodehostname function should return the expected value.

The following table is used only to test the name of the host. It is necessary to make sure that the path, fragment and original URL parameters are kept unchanged.

ProxyurlDecodehostname
HTTPS: // Example-Kom. Translavite. Hogoexample.com
HTTPS: //fo-example-kom. Translavite. HogogFu. Example.kom
HTTPS: //fo--- Example-kom. Translavite. HogogFOOO-Example.Kom
HTTPS: //0-57XH060O-oKO.SALYT. GOOG/? _C_TR_ENTS = 0Hn-57XH060O.K.
https: // 1-en--us-example-com/? _x_tr_enc = 1EN-USA EXMPLE.K.
https: //lanfairpwlgwyngylgogogogorychwyrndrobwllantyogogogocho-co-uk.translate .GOOG/? _ x_TR_HP = lllanfairpwlgwyngylgogoGogoRndrobwllantysiliogogogoch.co.ukLllanfirepvlgvalgogergartychyrndrovlelandiliogogogochch.So.uk

If you have questions about the integration of transfers on your site and the correct display of advertising, you can contact the SEO.computer SEO company for any issue for email info@seo.computer Or in WhatsApp +79202044461.

ID 168

Send a request and we will provide a consultation on SEO promotion of your website