AdSense Integration
NOW-LMS includes comprehensive Google AdSense integration that allows administrators to monetize free courses while providing a premium, ad-free experience for paid course users.
Overview
The AdSense integration supports 8 specific Google-recommended ad sizes with strategic placement throughout the platform:
- Leaderboard (728×90) - Top-performing banner format
- Medium Rectangle (300×250) - Embeddable within content
- Large Rectangle (336×280) - High-inventory large rectangle
- Mobile Banner (300×50) - Mobile-friendly banner
- Wide Skyscraper (160×600) - Sidebar placement
- Skyscraper (120×600) - Traditional sidebar ad
- Large Skyscraper (300×600) - Large sidebar format
- Billboard (970×250) - Large top placement
Business Logic
Ads are strategically displayed only when: 1. Global ads are enabled by administrators 2. Course is free (not paid)
This ensures a non-intrusive monetization strategy that respects paid course users while generating revenue from free content.
Configuration
Accessing AdSense Settings
- Log in as an administrator
- Navigate to Settings → AdSense Configuration
- Configure your AdSense integration
Basic Setup
- Publisher ID: Enter your Google AdSense publisher ID (pub-XXXXXXXXXXXXXXXXX)
- Meta Tag: Add your AdSense verification meta tag if required
- Enable Meta Tag: Check if you want to include the meta tag in your site's header
- Show Ads Globally: Master switch to enable/disable all ads across the platform
Ad Code Configuration
For each ad size, you can configure specific AdSense code:
Leaderboard (728×90)
Best for header/footer placement. Ideal for desktop users.
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-XXXXXXXXXXXXXXXXX"
crossorigin="anonymous"></script>
<!-- Leaderboard -->
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-XXXXXXXXXXXXXXXXX"
data-ad-slot="XXXXXXXXXX"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
Medium Rectangle (300×250)
Embeddable within content. Used in course sidebars.
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-XXXXXXXXXXXXXXXXX"
crossorigin="anonymous"></script>
<!-- Medium Rectangle -->
<ins class="adsbygoogle"
style="display:inline-block;width:300px;height:250px"
data-ad-client="ca-pub-XXXXXXXXXXXXXXXXX"
data-ad-slot="XXXXXXXXXX"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
Large Rectangle (336×280)
High-inventory format. Used after resource descriptions.
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-XXXXXXXXXXXXXXXXX"
crossorigin="anonymous"></script>
<!-- Large Rectangle -->
<ins class="adsbygoogle"
style="display:inline-block;width:336px;height:280px"
data-ad-client="ca-pub-XXXXXXXXXXXXXXXXX"
data-ad-slot="XXXXXXXXXX"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
Mobile Banner (300×50)
Optimized for mobile devices.
Skyscraper Formats
Vertical ads ideal for sidebar placement:
- Wide Skyscraper (160×600)
- Skyscraper (120×600)
- Large Skyscraper (300×600)
Billboard (970×250)
Large format for prominent placement.
Ad Placement
Course Pages
- Medium Rectangle (300×250) ads appear in the course sidebar for free courses
- Ads are clearly labeled with "Publicidad" for transparency
Resource Pages
- Large Rectangle (336×280) ads appear after resource descriptions for free courses
- Strategic placement that doesn't interfere with learning content
Global Settings
- Ads only display when globally enabled AND the course is free
- All ads respect the
not curso.pagado
condition
ads.txt Compliance
NOW-LMS automatically generates a compliant ads.txt
file at /ads.txt
that meets Google's requirements:
- Proper
text/plain; charset=utf-8
content-type - Correct format:
google.com, pub-{your-publisher-id}, DIRECT, f08c47fec0942fa0
- Graceful handling of missing publisher IDs
Verifying ads.txt
- In AdSense settings, click "Verificar archivo ads.txt"
- This will open your site's ads.txt file in a new tab
- Verify it contains your publisher ID in the correct format
Theme Compatibility
The AdSense integration works across all NOW-LMS themes:
- Cambridge
- Classic
- Corporative
- Finance
- Harvard
- Ocean Blue
- Oxford
- Rose Pink
All theme template overrides have been updated to include the same strategic ad placement.
Template Functions
The following Jinja2 functions are available in templates:
Global Functions
adsense_enabled()
- Check if ads are globally enabledad_leaderboard()
- Get leaderboard ad codead_medium_rectangle()
- Get medium rectangle ad codead_large_rectangle()
- Get large rectangle ad codead_mobile_banner()
- Get mobile banner ad codead_wide_skyscraper()
- Get wide skyscraper ad codead_skyscraper()
- Get skyscraper ad codead_large_skyscraper()
- Get large skyscraper ad codead_billboard()
- Get billboard ad code
Error Handling
All functions return empty strings when: - Ads are disabled globally - Ad content is missing or empty - Database connectivity issues occur
Best Practices
Content Guidelines
- Respect User Experience: Ads only appear on free content
- Clear Labeling: All ads are labeled as "Publicidad"
- Strategic Placement: Ads don't interfere with learning content
- Responsive Design: Ad codes should include responsive units when possible
Google AdSense Policies
- Ensure your content complies with Google AdSense Content Policies
- Follow Google AdSense Program Policies
- Maintain appropriate content-to-ad ratios
- Don't encourage clicks or interactions with ads
Performance Optimization
- Use async loading for all ad scripts
- Consider lazy loading for below-the-fold ads
- Monitor Core Web Vitals impact
- Test ad performance across different devices
Troubleshooting
Ads Not Displaying
- Verify that Show Ads Globally is enabled
- Ensure the course is free (not paid)
- Check that ad codes are properly configured
- Verify your AdSense account is approved
ads.txt Issues
- Check that your publisher ID is correctly entered
- Verify the ads.txt file is accessible at your domain root
- Ensure proper DNS and hosting configuration
Theme Issues
- Verify the theme supports AdSense integration
- Check that theme overrides include updated templates
- Clear any template caches
Migration Notes
For existing NOW-LMS installations:
- The AdSense integration adds new database fields automatically
- No manual database migrations are required for alpha releases
- Existing AdSense configurations are preserved
- New ad size fields default to empty strings
Support
For technical support with AdSense integration:
- Check this documentation first
- Verify your Google AdSense account status
- Review Google's AdSense Help Center
- Contact NOW-LMS support for platform-specific issues
Note: This feature requires an approved Google AdSense account. Ad revenue and performance depend on factors outside of NOW-LMS control, including content quality, traffic volume, and AdSense policies.