Charger le tag d'emplacement publicitaire via HTTPS
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Présentation
Les scripts de bibliothèque de tags d'emplacement publicitaire sont demandés de manière sécurisée. Non seulement cela
renforce la sécurité de vos utilisateurs, mais améliore également les performances. Depuis l'annonce
les demandes émises par les tags GPT utilisent toujours le protocole HTTPS, en chargeant la bibliothèque elle-même à partir du
hôte recommandé via HTTPS garantit que
le navigateur n'a besoin d'ouvrir qu'une seule connexion pour toutes les demandes liées à la diffusion d'annonces.
Recommandations
Chargez toujours les scripts de vos tags d'emplacement publicitaire à partir d'une URL HTTPS.
Réponse incorrecte
<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>
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/25 (UTC).
[null,null,["Dernière mise à jour le 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"]]