Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(google-adsense): add Auto Ads support and improve script injection #366

Merged
merged 9 commits into from
Feb 7, 2025

Conversation

nexoscreator
Copy link
Contributor

@nexoscreator nexoscreator commented Jan 30, 2025

πŸ”— Linked issue

No

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Code Changes

  • Added autoAds option to enable or disable Auto Ads dynamically.
  • Modified scriptInput.src to append ?client=ca-pub-XXXXXX dynamically.
  • Injected an inline script when autoAds is enabled to support automatic ad placement.
  • Improved TypeScript types for better validation and usability.

Documentation Updates

  • Updated the Google Adsense documentation to include autoAds configuration.
  • Added a Global Configuration section in nuxt.config.ts to illustrate usage.
  • Expanded Component API details with data-ad-format and data-ad-layout for in-article and in-feed ads.
  • Provided site verification instructions using a meta tag and ads.txt file.

πŸ“· Screenshots (if applicable)

N/A

βœ… Checklist

  • My code follows the project’s coding style and guidelines.
  • I have updated the documentation accordingly.
  • I have tested the changes locally to ensure they work as expected.
  • I have checked for potential breaking changes.

- Added `autoAds` option to enable or disable Auto Ads dynamically.
- Modified `scriptInput.src` to append ?`client=ca-pub-XXXXXX` dynamically.
Copy link

vercel bot commented Jan 30, 2025

@nexoscreator is attempting to deploy a commit to the Nuxt Team on Vercel.

A member of the Team first needs to authorize it.

@harlan-zw
Copy link
Collaborator

Thank you for the work on this PR, as I don't use Google Adsense myself your feedback is really helpful.

All looks good although I'm a bit confused on "Auto Ads". Is this something from Google Ad vocabulary or is this something you've created?

It seems like we can possibly just always init the adsbygoogle array? Do you think this would cause any issues? Although end users should be able to configure enable_page_level_ads explicitly if this does something.

@nexoscreator
Copy link
Contributor Author

nexoscreator commented Jan 31, 2025

Thank you for the work on this PR, as I don't use Google Adsense myself your feedback is really helpful.

All looks good although I'm a bit confused on "Auto Ads". Is this something from Google Ad vocabulary or is this something you've created?

It seems like we can possibly just always init the adsbygoogle array? Do you think this would cause any issues? Although end users should be able to configure enable_page_level_ads explicitly if this does something.

Thank you for reviewing my PR!

Regarding your question about "Auto Ads", it is an official term used by Google AdSense. Auto Ads automatically place ads on a page based on Google's algorithm. Here is the official documentation for reference: Google AdSense Auto Ads.

As for initializing the adsbygoogle array, I believe it should be safe to always initialize it. However, enabling enable_page_level_ads explicitly might be preferable to give end users more control over whether they want Auto Ads or not. If we initialize the array unconditionally, it shouldn't cause issues, but it would be good to clarify whether all users would expect this behavior.

@harlan-zw harlan-zw merged commit 455117d into nuxt:main Feb 7, 2025
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants