Closed (fixed)
Project:
Google AdSense integration
Version:
8.x-1.0
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
7 Dec 2017 at 12:58 UTC
Updated:
13 Feb 2019 at 12:13 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
Prez13 commentedComment #3
pvsureshmca commentedYes. I got the same issue
Comment #4
pvsureshmca commentedComment #5
atuljaiswal1296@gmail.com commentedHi,
I am facing the same issue that is the reason google adSense is not able to verify the account. Can you please let me know when this issue will be fixed or anyone have any alternative way to fix it. Please help me.
Regards,
Atul
Comment #6
jcnventuraCan you try to replace 'script' with '' in line 61 of adsense.module and tell me if that fixes the problem?
Comment #7
jwillers commentedYes, it fixed it for me, but now there are empty tags.
<>at the beginning and</>at the endThis puts the
<>at the top of each page. But at least the ads work...EDIT: Changing it to "meta" also lets it work and doesn't add the
<>to the top of the site.EDIT2: If you also change the tags of the previous two arrays to "meta" you remove the
<>at the top of the pages when ads are disabled or not on the list as well.Comment #8
nuwans commentedHello,
For this issue, I m using the following patch.
Comment #9
nuwans commentedComment #10
asak commentedStumbled across this as well. I believe it's related to changes in D8.4 (upgraded from 8.3)
Patch #9 solves it.
Comment #11
tamerzg commentedRegarding <> see this patch #2948088: <> and this core issue #2968883: Empty #tag in HtmlTag causes <> to be printed at the top of the pages.
Comment #12
tamerzg commentedAttached is improved patch from #9:
- removed code related to #2948088: <> as its seperate issue with a different patch
- pagead2.googlesyndication.com/pagead/js/adsbygoogle.js is added as library instead of being attached through html_tag. html_tag is intended for inline JS code or metatags not external scripts. Also will open another issue to replace loading of pagead2 from library on other places too.
- removed adsense-managed-page-level.html.twig and adsense_managed_page_level theme declaration.
Comment #13
jcnventuraLibrary attachment is OK, but why remove the html twig?
Comment #14
tamerzg commentedThat Twig file is not used anymore. It only purpose was to add inline JS via html_tag but thats wrong, now inline JS is added proper way via html_tag.
Comment #15
tamerzg commentedFollowing up on our email conversation I am pasting my answer here so others could potentially be included in converstation too:
jcnventura: Please keep the twig template. PHP code should not be generating HTML (even if that HTML is Javascript).
tamerzg: As for PHP code generating HTML, issue here is that Drupal html_tag is not envisioned to add inline scripts in that way. We would need to remove script> part from twig since those tags will already be generated by html_tag so we would be left with a twig file which has only following:
Which for me is bit more messy than putting it directly in #value part of render array. The later approach is also documented in https://www.drupal.org/docs/8/creating-custom-modules/adding-stylesheets... under "Inline JavaScript that affects the entire page".
Comment #16
skymen commentedHi, guys. Replace string 61 in adsense.module
'#tag' => 'script',by'#type' => 'markup',. This fix this issue.Comment #17
jcnventuraUsing 'inline_template' (and providing an empty template...) seems to be the best work-around for this issue.
Comment #19
jcnventuraComment #21
VishalKumarSahu commentedTo temporarily solve the problem I followed this approach-
And another solution is to adjust the twig templates accordingly.