I am trying to make a theme component to display Carbon Ads in my Discourse forum
Carbon Ads are called by inserting the following code where they should be loaded:
<script src="//cdn.carbonads.com/carbon.js?serve=CK7DL2Q7&placement=wwwkodulario" id="_carbonads_js" async type="text/javascript"></script>
In the Theme Component, after checking the guide , I came to the conclussion that the easiest way to do so is by using plugin outlets
However, when I add the following piece of code to </head> I get the following error:
Error: Unclosed element script (on line 2).
<script type="text/x-handlebars" data-template-name="/connectors/topic-above-post-stream/foobar">
<script src="//cdn.carbonads.com/carbon.js?serve=CK7DL2Q7&placement=wwwkodulario" id="_carbonads_js" async type="text/javascript"></script>
</script>
I guess it is because I should not be supposed to use a script tag inside another script tag, but how can I fix it? Is there any workaround for this?
justin
(Justin DiRose)
April 6, 2019, 7:48pm
2
Have you tried putting the script call in the </head> file without the text/x-handlebars script tag? I haven’t tried this before, but it’s worth a shot as that imports into the application.
4 Likes
Yep, it worked!
But the script is not being executed
I mean, the JavaScript is not being triggered as the ad is not loading
Any idea why it’s not working?
I’ve finally gone for the plugin way, and opened a PR to add Carbon Ads to Discourse-AdPlugin:
master ← barreeeiroo:master
merged 03:54PM - 15 Apr 19 UTC
This PR adds Carbon Ads support to Discourse-AdPlugin
```
CARBON ADS GUIDE… LINES
There can be only one ad per page.
The ad should be visible above-the-fold (upper 800 pixels) for desktop browser.
The ad should be visible within 3x of the mobile viewport height, starting from the top of the mobile browser.
The ad tag should be placed exactly where you'd like the ad to display.
The ad image must remain 130 × 100 pixels, unmodified and unobscured.
The ad text is up to 80 characters in length and must be clearly visible.
```
To comply with this, there are only two possible locations for the ad: above topic lists and above posts stream.
---




5 Likes
neil
(Neil Lalonde)
April 9, 2019, 3:56pm
5
@codinghorror is using Carbon Ads on his blog, so I’m inclined to approve your PR and include it in our official plugin. I’ll review.
6 Likes
neil
(Neil Lalonde)
April 15, 2019, 3:56pm
6
PR is merged. Thanks @barreeeiroo .
7 Likes