Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

248
Vistas
how can target specific URLs in my website with DFP (House)

I am implement in AnguarJs application and use Javascript so please help me how to pass dynamic url (page name) in our code.

<script>
        window.googletag = window.googletag || { cmd: [] };
        googletag.cmd.push(function () {
            var pathname = window.parent.location.pathname;
            var length = 40;`enter code here`
            var url = pathname.substring(1, length).replace(/[!@#$%^&*/()_-]/g, "");
            googletag.defineSlot('/14616973/cbcs_dt_1_728x90_1', [728, 90], 'div-gpt-ad-1604917677506-1').addService(googletag.pubads());
            googletag.defineSlot('/14616973/cbcs_dt_2_728x90_2', [728, 90], 'div-gpt-ad-1604917677506-2').addService(googletag.pubads());
            googletag.defineSlot('/14616973/cbcs_dt_3_300x250_1', [300, 250], 'div-gpt-ad-1604917677506-3').addService(googletag.pubads());
            googletag.defineSlot('/14616973/cbcs_dt_4_300x600_1', [300, 600], 'div-gpt-ad-1604917677506-4').addService(googletag.pubads());
            googletag.defineSlot('/14616973/cbcs_mb_1_300x250_1', [300, 250], 'div-gpt-ad-1604918658528-1').addService(googletag.pubads());
            googletag.defineSlot('/14616973/cbcs_mb_1_300x250_2', [300, 250], 'div-gpt-ad-1604918658528-2').addService(googletag.pubads());
            googletag.defineSlot('/14616973/cbcs_mb_3_300x600_3', [300, 600], 'div-gpt-ad-1604918658528-3').addService(googletag.pubads());
            googletag.pubads().setTargeting('Sub_Category', []).setTargeting('Cat', []).setTargeting('url', [url]).setTargeting('search', []).setTargeting('Page', []);
            googletag.pubads().collapseEmptyDivs();
            googletag.enableServices();
        });
    </script>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

As detailled here, if your key has a single value, you should send a string :

var pathname = window.parent.location.pathname;
var length = 40;
var url = pathname.substring(1, length).replace(/[!@#$%^&*/()_-]/g, "");

..
googletag.pubads().setTargeting('url', url);

To be able to target a specific page, you could also pass the page or content ID to GPT : it avoids having duplicates as the 40 caracters length limitation for values might end up with similar value for different pages... (it depends on the way your page URLs are built).

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda