Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-02-2012, 06:22 AM
twiforum twiforum is offline
 
Join Date: Jan 2011
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Question about ntegrating Google DFP asynchronous tags

I'm trying to integrate DFP Google publisher asynchronous tags on our installation; which requires the following header code:

HTML Code:
<script type='text/javascript'>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
(function() {
var gads = document.createElement('script');
gads.async = true;
gads.type = 'text/javascript';
var useSSL = 'https:' == document.location.protocol;
gads.src = (useSSL ? 'https:' : 'http:') +
'//www.googletagservices.com/tag/js/gpt.js';
var node = document.getElementsByTagName('script')[0];
node.parentNode.insertBefore(gads, node);
})();
</script>

<script type='text/javascript'>
googletag.cmd.push(function() {
googletag.defineSlot('/1013431/TWILike_Forum_160', [160, 600], 'div-gpt-ad-1325472136197-0').addService(googletag.pubads());
googletag.defineSlot('/1013431/TWILike_Forum_300', [300, 250], 'div-gpt-ad-1325472136197-1').addService(googletag.pubads());
googletag.defineSlot('/1013431/TWILike_Forum_728', [728, 90], 'div-gpt-ad-1325472136197-2').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
I've tried adding this code to headerinclude at the end. The first block of javascript shows up in the page source when added, but the second block doesn't show up and I get an "unclosed curly brace expression" error.

I've tried enclosed the entire code block in <vb:literal> tags. I've tried enclosing first one block and then the other. But nothing I can do will get that second block to show up.

Any advice/suggestions would be greatly appreciated...
Reply With Quote
  #2  
Old 01-07-2012, 03:28 PM
del Drago's Avatar
del Drago del Drago is offline
 
Join Date: Dec 2010
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm having the same issue. Any help would be appreciated.

Thanks.

--------------- Added [DATE]1325956848[/DATE] at [TIME]1325956848[/TIME] ---------------

Okay, I think that I figured out the issue. Perhaps this will help someone else.

First, to avoid the "unclosed curly brace expression" error, the code added to the header must be enclosed in <vb:literal> tags as such:

Code:
<vb:literal>

</vb:literal>
Now for me, the reason that the second ad wasn't showing was because I had generated new tag codes after inserting the first ad.

Apparently every time that you generate tags, all of the header codes change. So... if you should generate new tags for any reason, you need to go into the headerinclude template and completely replace the header code from before.

I hope that this is helpful to someone.
Reply With Quote
  #3  
Old 05-23-2012, 03:34 PM
xlguy's Avatar
xlguy xlguy is offline
 
Join Date: Feb 2004
Location: UK
Posts: 168
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is there a similar way of getting this to work on 3.8? Is there a literal tag, or any easy way of creating the same effect?
Reply With Quote
  #4  
Old 05-23-2012, 09:49 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by xlguy View Post
Is there a similar way of getting this to work on 3.8? Is there a literal tag, or any easy way of creating the same effect?
Try escaping each single quote...

Basically use a text editor and do a find/replace

find: '
replace: \'

paste the new code into the template and try again.
Reply With Quote
  #5  
Old 05-24-2012, 09:13 AM
xlguy's Avatar
xlguy xlguy is offline
 
Join Date: Feb 2004
Location: UK
Posts: 168
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi, thanks for that but unfortunately it's not that simple (I did try after your suggestion).

I think it's to do with the {} or perhaps the fact this code uses function names?

In headerinclude I'm putting:

HTML Code:
<script type='text/javascript'>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
(function() {
var gads = document.createElement('script');
gads.async = true;
gads.type = 'text/javascript';
var useSSL = 'https:' == document.location.protocol;
gads.src = (useSSL ? 'https:' : 'http:') + 
'//www.googletagservices.com/tag/js/gpt.js';
var node = document.getElementsByTagName('script')[0];
node.parentNode.insertBefore(gads, node);
})();
</script>

<script type='text/javascript'>
googletag.cmd.push(function() {
googletag.defineSlot('/100XX/160sky', [160, 600], 'div-gpt-ad-XX-0').addService(googletag.pubads());
googletag.defineSlot('/100XX/728-90-inpost', [728, 90], 'div-gpt-ad-XX-1').addService(googletag.pubads());
googletag.defineSlot('/100XX/728x90', [728, 90], 'div-gpt-ad-XX-2').addService(googletag.pubads());
googletag.defineSlot('/100XX/468banner', [468, 60], 'div-gpt-ad-XX-3').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
In my templates, to call an ad (for example) 160sky, I put:

HTML Code:
<div id='div-gpt-ad-XXXX-0' style='width:160px; height:600px;'>
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-XX-0'); });
</script>
</div>
Any ideas? Thanks
Reply With Quote
  #6  
Old 05-25-2012, 12:54 AM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Maybe just put the javascript in an external file and call it the usual way?

http://www.tizag.com/javascriptT/javascriptexternal.php
Reply With Quote
  #7  
Old 07-04-2014, 06:59 PM
brandondrury brandondrury is offline
 
Join Date: Oct 2005
Posts: 136
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I got it to work by moving all the DFP code to an external .js file. I had to remove the "<script>" and "</script" tags.

Brandon
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:44 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05038 seconds
  • Memory Usage 2,224KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (3)bbcode_html
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete