Code implementation guide

Copy the code

You need to copy and paste the following two snippets of code into the premium-content pages where you want to show Google Surveys.

1. Place this JavaScript tag right after your <body> tag. Substitute GSACCOUNTID for the account ID found in your Google Surveys publisher dashboard under Settings. Your GSACCOUNTID is not the same as your AdSense publisher ID.

<script type="text/javascript">
(function() {
  var ARTICLE_URL = window.location.href;
  var CONTENT_ID = 'everything';
  document.write(
    '<scr'+'ipt '+
    'src="//survey.g.doubleclick.net/survey?site=_GSACCOUNTID'+
    '&amp;url='+encodeURIComponent(ARTICLE_URL)+
    (CONTENT_ID ? '&amp;cid='+encodeURIComponent(CONTENT_ID) : '')+
    '&amp;random='+(new Date).getTime()+
    '" type="text/javascript">'+'\x3C/scr'+'ipt>');
})();
</script>

 

2. Wrap your premium content in a div class named 'p402_premium' so that this class can be targeted to display the microsurvey and gray out the premium content.
 

<div class="p402_premium">
    <!-- YOUR PREMIUM CONTENT HERE -->
</div>

 

3. Include the JavaScript tag right after the 'p402_premium' </div> tag. Up to 150 characters of text are shown by default. If this JavaScript tag is not included, the survey prompt may not appear correctly on the page.

<script type="text/javascript"> 
  try { _402_Show(); } catch(e) {} 
</script>

4. Select the code snippets above (the selection will be highlighted).

5. From your browser's Edit menu, choose Copy to copy the highlighted area.

Some sites might contain conflicting elements such as attribution, story photos, sidebars, and social sharing toolbars that border their premium content. See Adding Surveys code to pages with conflicting elements for an additional snippet of code to include in such pages.

Was this helpful?
How can we improve it?