Diferencia entre revisiones de «MediaWiki:Common.js»
De Dicionário de História Cultural de la Iglesía en América Latina
Ir a la navegaciónIr a la búsqueda| (No se muestra una edición intermedia del mismo usuario) | |||
| Línea 4: | Línea 4: | ||
scriptElement.async = true; | scriptElement.async = true; | ||
scriptElement.src = "https://www.googletagmanager.com/gtag/js?id=G-BLPMLEYW7K"; | scriptElement.src = "https://www.googletagmanager.com/gtag/js?id=G-BLPMLEYW7K"; | ||
| + | // Adjuntar el elemento <script> al final del <head> del documento | ||
| + | document.head.appendChild(scriptElement); | ||
| + | |||
| + | // Crear el elemento <script> para el fragmento de código | ||
var scriptElement2 = document.createElement("script"); | var scriptElement2 = document.createElement("script"); | ||
| − | scriptElement2.textContent = | + | |
| + | // Agregar el contenido del fragmento de código al elemento <script> | ||
| + | scriptElement2.textContent = ` | ||
window.dataLayer = window.dataLayer || []; | window.dataLayer = window.dataLayer || []; | ||
function gtag(){dataLayer.push(arguments);} | function gtag(){dataLayer.push(arguments);} | ||
gtag('js', new Date()); | gtag('js', new Date()); | ||
gtag('config', 'G-BLPMLEYW7K'); | gtag('config', 'G-BLPMLEYW7K'); | ||
| − | + | `; | |
| − | // Adjuntar el elemento <script> al final del < | + | // Adjuntar el elemento <script> al final del <body> del documento |
| − | document. | + | document.body.appendChild(scriptElement2); |
| − | |||
Revisión actual del 11:18 16 ago 2023
/* Cualquier código JavaScript escrito aquí se cargará para todos los usuarios en cada carga de página */
// Crear el elemento <script> para la carga de gtag.js
var scriptElement = document.createElement("script");
scriptElement.async = true;
scriptElement.src = "https://www.googletagmanager.com/gtag/js?id=G-BLPMLEYW7K";
// Adjuntar el elemento <script> al final del <head> del documento
document.head.appendChild(scriptElement);
// Crear el elemento <script> para el fragmento de código
var scriptElement2 = document.createElement("script");
// Agregar el contenido del fragmento de código al elemento <script>
scriptElement2.textContent = `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-BLPMLEYW7K');
`;
// Adjuntar el elemento <script> al final del <body> del documento
document.body.appendChild(scriptElement2);