Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

249
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!