Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Panoramica
Assicura che gli script della libreria di tag annuncio vengano richiesti in modo sicuro. Questo non solo
migliora la sicurezza degli utenti e le prestazioni. Poiché l'annuncio
richieste inviate da GPT utilizzano sempre HTTPS, caricando la libreria stessa dal
host consigliato tramite HTTPS garantisce che
Il browser deve aprire una sola connessione per tutte le richieste relative alla pubblicazione di annunci.
Consigli
Carica sempre gli script dei tag annuncio da un URL HTTPS.
Risposta sbagliata
<script>
var el = document.createElement('script');
// Incorrect: potentially loading the ad tag over HTTP.
var useSSL = 'https:' == document.location.protocol;
el.src = (useSSL ? 'https:' : 'http:') + '//securepubads.g.doubleclick.net/tag/js/gpt.js';
var node = document.getElementsByTagName('script')[0];
node.parentNode.insertBefore(el, node);
</script>
[null,null,["Ultimo aggiornamento 2025-07-25 UTC."],[[["\u003cp\u003eLoading ad tag library scripts securely over HTTPS enhances security and performance for users.\u003c/p\u003e\n"],["\u003cp\u003eBrowsers establish a single connection for ad serving when GPT and its library are fetched via HTTPS.\u003c/p\u003e\n"],["\u003cp\u003eAd tag scripts should always be loaded from an HTTPS URL for optimal security.\u003c/p\u003e\n"],["\u003cp\u003eGoogle Publisher Tag and AdSense are among the supported ad tag library scripts, and their HTTPS URLs are provided for reference.\u003c/p\u003e\n"]]],["Ad tag library scripts should be loaded via HTTPS for enhanced security and performance. Always use HTTPS URLs to load scripts; avoid HTTP. Secure loading ensures a single browser connection for all ad-related requests, as GPT uses HTTPS. Supported scripts include those for AdSense (e.g., `pagead2.googlesyndication.com/pagead/js/adsbygoogle.js`) and Google Publisher Tag (e.g., `securepubads.g.doubleclick.net/tag/js/gpt.js`). The correct implementation is loading scripts such as `https://securepubads.g.doubleclick.net/tag/js/gpt.js` using the script tag.\n"],null,["# Load ad tag over HTTPS\n\nOverview\n--------\n\nEnsures that ad tag library scripts are being requested securely. This not only\nprovides better security for your users, it also improves performance. Since ad\nrequests issued by GPT always use HTTPS, loading the library itself from the\n[recommended host](./loads-gpt-from-official-source) via HTTPS ensures that the\nbrowser only needs to open 1 connection for all requests related to ad serving.\n| **Note:** This should only fail on non-secure websites, as most secure websites will automatically load scripts using HTTPS.\n\nRecommendations\n---------------\n\nAlways load your ad tag scripts from an HTTPS URL.\n\n|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| **Incorrect** | ```html \u003cscript\u003e var el = document.createElement('script'); // Incorrect: potentially loading the ad tag over HTTP. var useSSL = 'https:' == document.location.protocol; el.src = (useSSL ? 'https:' : 'http:') + '//securepubads.g.doubleclick.net/tag/js/gpt.js'; var node = document.getElementsByTagName('script')[0]; node.parentNode.insertBefore(el, node); \u003c/script\u003e ``` |\n| **Correct** | ```html \u003cscript async src=\"https://securepubads.g.doubleclick.net/tag/js/gpt.js\"\u003e\u003c/script\u003e ``` |\n\nMore information\n----------------\n\nThe following ad tag library scripts are supported:\n\n| Library | Script(s) |\n|----------------------|-------------------------------------------------------------------------------------------------------------|\n| AdSense | `pagead2.googlesyndication.com/pagead/js/adsbygoogle.js` `pagead2.googlesyndication.com/pagead/show_ads.js` |\n| Google Publisher Tag | `googletagservices.com/tag/js/gpt.js` `securepubads.g.doubleclick.net/tag/js/gpt.js` |\n\n[Get Started with Google Publisher Tags](https://developers.google.com/publisher-tag/guides/get-started) \n[View audit source](https://github.com/googleads/publisher-ads-lighthouse-plugin/tree/HEAD/lighthouse-plugin-publisher-ads/audits/loads-ad-tag-over-https.js) [Improve this article](https://github.com/googleads/publisher-ads-lighthouse-plugin/tree/HEAD/docs/audits/loads-ad-tag-over-https.md) [Report an issue](https://github.com/googleads/publisher-ads-lighthouse-plugin/issues/new?labels=documentation&template=documentation-feedback.md&title=Documentation+feedback%3A+loads-ad-tag-over-https.md)\n\n\u003cbr /\u003e"]]