Forum OpenACS Development: Adding Google AdSense tags to page header

Hi there, Adding a script library in the header of an OpenACS website, to support Google AdSense, would be a pretty easy task.

Amending /www/blank-master.adp, by adding the follwing chunk in the last line before head closure

... <script data-ad-client="ca-pub-86757473464" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
</head>
...

However, I was wondering how would I use ad_proc template::head::add_javascript to this case

Being very specifically how would I pass the argument '... data-ad-client="ca-pub-86757473464"' through the ad_proc call.

Best wishes, I

/api-doc/proc-view?proc=template::head::add_script

Collapse
Posted by Brian Fenton on
Hi Iuri

I think you can just the -script parameter to template::head::add_javascript e.g. https://openacs.org/api-doc/proc-view?proc=template::head::add_javascript&source_p=1

Brian

Collapse
Posted by Iuri Sampaio on
Hi Brian,

Thanks for the tip. Yes, they work indeed.
However, I was looking for a standard approach to add new arguments to a ad_proc call.

So, I've written a new version of template::head::add_javascript .

Basically, I copied and pasted 100% of that ad_proc, then I added custom code to extend and support Google parameters. It worked beautifully!

Happy Easter!
I