Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: guiller_mote on February 01, 2023, 12:18:58 PM

Title: Error with Google AdManager tags
Post by: guiller_mote on February 01, 2023, 12:18:58 PM
SMF 2.0.19
PHP 8.0

Hi all.
Much apreciated if somebody can help me.

I created a tag in google AdManager that works because I have also WordPress in the same domain and works fine. However in SMF it doesn't work neither with SMFPacks Ads Manager Mod (Adsense tags withot problems) nor manually insert. With this last option I get an error that sais, "template main_above cannot be load" (Adsense manually in the same location also works without any problems).
Any idea about this issue?

Thanks in advanced and best regards.
Title: Re: Error with Google AdManager tags
Post by: Kindred on February 01, 2023, 01:34:53 PM
well, from the error, it would appear that you probably just pasted the google code into the index.template.php file without actually parsing it into the template/php...  You can't just randomly paste code into a php file.

you have to have it in an echo statement and you have to escape single quotes.
Title: Re: Error with Google AdManager tags
Post by: guiller_mote on February 01, 2023, 03:07:40 PM
Hi Kindred.

Thanks for your quick response.
As you see I'm not a php expert, only did the same as with the Adsense tag that works without any echo statement, I thought that will be the same :).
Please, tell me what exactly I have to write before and after AdManager tag.

The tag is something like this
<!-- /21632378801/300x250 -->
<div id='div-gpt-ad-16753456786-0' style='min-width: 300px; min-height: 90px;'>
  <script>
    googletag.cmd.push(function() { googletag.display('div-gpt-ad-16753456786-0'); });
  </script>
</div>

Thanks for your help.
Title: Re: Error with Google AdManager tags
Post by: vbgamer45 on February 01, 2023, 03:22:31 PM
There should be more to the code than just that. Some kind of javsacript file include too
Title: Re: Error with Google AdManager tags
Post by: guiller_mote on February 01, 2023, 03:57:50 PM
Hi Vbgamer.

Yes, that's right but the other part of the code that you say goes in head section and I have no issues with it using Global Headers and Footers mod, I suppose that this mod is internally responsible for doing things well not like me  ;D .
Title: Re: Error with Google AdManager tags
Post by: vbgamer45 on February 01, 2023, 04:00:53 PM
If you can see the code on the page that means it is ok.
Other than that google takes some time for ads to appear.
And you must have updated your ads.txt with the google publisher information
Title: Re: Error with Google AdManager tags
Post by: guiller_mote on February 01, 2023, 04:12:35 PM
Thanks for your help Vbgamer but that's not the issue. As I said in the first post I get a blank screen when just right enter to the forum an an error "template main_above cannot be load", it is clear that some code is missing to put from my side but the person that don't know is like the one that don't see (as we say in Spain  ;) ).
In the other hand I have "hundreds" of Adsense tags delivered for the rest of the web and work fine, it is only when I use ADM.
Title: Re: Error with Google AdManager tags
Post by: vbgamer45 on February 01, 2023, 04:21:08 PM
I would talk to the mod author in that case.
Title: Re: Error with Google AdManager tags
Post by: guiller_mote on February 01, 2023, 04:29:39 PM
It is complicated, it is not a mod it is SAINT GOOGLE  :laugh:
Title: Re: Error with Google AdManager tags
Post by: guiller_mote on February 01, 2023, 04:35:04 PM
 :o  :o  :o  :o
I had not seen the logo banner on this website, it is just my case and I could have explained it better, sorry.
I have an equal 468x60 Adsense one embedded by hand in the indextemplate.php and works without problems, but now I want to use Google Ad Manager to rotate banners from other agencies and not just from Adsense but the code provided by ADM makes the web break.
I hope that now I have understood better.
Title: Re: Error with Google AdManager tags
Post by: Kindred on February 01, 2023, 08:34:29 PM
You have single quotes... they need to be replaced with double quotes or escaped
Title: Re: Error with Google AdManager tags
Post by: guiller_mote on February 02, 2023, 04:31:23 AM
Many thanks Kindred !!!

Now I don't get blank screen and the banner is shown perfect with rotation after change all ' by ". Until there good but all the text in the web is center instead of left ¿?¿?
Please, help again.
Or tell me what did you mean by "they need to be replaced with double quotes or escaped", let me know please this second posibility to see if work better.
Title: Re: Error with Google AdManager tags
Post by: Kindred on February 02, 2023, 08:49:35 AM
<!-- /21632378801/300x250 -->
<div id="div-gpt-ad-16753456786-0" style="min-width: 300px; min-height: 90px;">
  <script>
    googletag.cmd.push(function() { googletag.display(/'div-gpt-ad-16753456786-0/'); });
  </script>
</div>
Title: Re: Error with Google AdManager tags
Post by: guiller_mote on February 02, 2023, 10:27:15 AM
Yes Kindred, it is that I did but still center text
Title: Re: Error with Google AdManager tags
Post by: Kindred on February 02, 2023, 12:10:06 PM
oh. that has nothing at all to do with the quotes or code....  that's just CSS.
try adding text-align: left; to the style declaration.

If not... then that's a problem with Google's output, not the included code -- and you'll have to drill down into the google output css
Title: Re: Error with Google AdManager tags
Post by: guiller_mote on February 07, 2023, 02:08:51 AM
Sorry for not having answered sooner but I have been fighting with this last thing that you told me all these days at times and I have not achieved anything, I leave it as impossible but thank you very much anyway. I will not bother you with this matter anymore because it is evident that my knowledge is scarce. I'll try to find another way to do it.

Thanks and regards.