YouTube Masthead: Custom Flash build guide

Implement a YouTube remarketing pixel

For web users, there's little worse than being targeted with the same creative message over and over. For advertisers, there's little worse than wasting media spend on irrelevant, static creative messaging.

One way to ensure a better user experience—increasing brand engagement and motivating conversions—is to retarget modified creative content to users who interacted with the advertiser's masthead ad on the YouTube homepage or their YouTube brand channel. These users have shown an explicit interest in the brand and should therefore be considered hot prospects.

Extract the pixel URL

The remarketing pixel that the YouTube sales contact provides will likely be embedded in an HTML document. To load the remarketing pixel in Flash, you must extract the pixel URL from the HTML.

Open the HTML document in a text editing program to see something like this code example:

<!-- Google Code for Some Campaign Remarketing List -->
    <script type="text/javascript">
    /* <![CDATA[ */
    var google_conversion_id = 123456789;
    var google_conversion_language = "en";
    var google_conversion_format = "0";
    var google_conversion_color = "000000";
    var google_conversion_label = "rAnd0m_str1nG";
    var google_conversion_value = 0;
    /* ]]> */
    <script type="text/javascript" src="">
    <div style="display:inline;">
    <img height="1" width="1" style="border-style:none;" alt="" src="//;label=01eSCKWxwQQu_aE2QM&amp;guid=ON&script=0"/>

The pixel URL that you need is inside the img TAG and src parameter, in bold text above.

If your YouTube contact sent you a pixel URL and not HTML code, skip this step and proceed to the instructions below for pixel implementation

Implement the pixel in Flash

When you're calling the Google-YouTube remarketing pixel from Flash, make sure that the URL is formatted correctly.

Example of an unedited URL:;label=01eSCKWxwQQu_aE2QM&amp;guid=ON&script=0


Example of a properly formatted URL:


In this example, &amp; was replaced with & in the properly formatted URL. You have to reformat in this way because a URL with the &amp; syntax doesn't behave properly when called from within Flash.

To call a remarketing pixel in a Flash creative:

  • Create a loadPixel function to load the pixel whenever you need to call the remarketing pixel, and pass the URL as a parameter of the loadPixel function.

The code snippet below calls the remarketing pixel on the exit of the creative. This is for clients who might need to remarket to the user who clicked through (exited) the creative:

AS2 code snippet

function loadPixel(trackingPixel){
  buttonInstanceName.onRelease = function(){
        enabler.exit("Exit Name");
        loadPixel("add your pixel URL here");

AS3 code snippet

function loadPixel(trackingPixel){
      var pixelLoader: Loader = new Loader();
      pixelLoader.load(new URLRequest(trackingPixel));
  buttonInstanceName.addEventListener(MouseEvent.CLICK, exitHandler);
  function exitHandler(event:MouseEvent){
      Enabler.exit("Exit Name");
      loadPixel("add your pixel URL here");

Implement multiple remarketing pixels

The functions in the code snippets for AS2 and AS3, above, support multiple pixel URLs without the need to duplicate code. Provided you pass the relevant pixel URL to the loadPixel function when you need to, it will load without issue.

To load multiple pixels, just call the loadPixel function and load different pixels:

loadPixel("Pixel URL 1");
loadPixel("Pixel URL 2");

For more information on loading pixels in a creative, see Call a pixel in a Flash creative.

Android-style image of the author of this page

Sarah is a DoubleClick Studio expert and author of this help page. Help her improve this article by leaving feedback below.

Was this article helpful?