Skip to content

Instantly share code, notes, and snippets.

@Tmeister
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tmeister/23acc536580f43335d4d to your computer and use it in GitHub Desktop.
Save Tmeister/23acc536580f43335d4d to your computer and use it in GitHub Desktop.
$(function(){
var fileRef = document.createElement('script');
fileRef.setAttribute("type","text/javascript");
fileRef.setAttribute("src", "//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js");
document.body.appendChild(fileRef);
/*Change the SELECTOR-HERE for the one you want to add */
$("SELECTOR-HERE").append('<br/><ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-4429314952077491" data-ad-slot="8849066704" data-ad-format="auto"></ins>');
$("SELECTOR-HERE").append('<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>');
});
@weslleyaraujo
Copy link

Hey @Tmeister,

Is this working just fine for you?

Im trying to implement GA + Optimizely but I always get the:

"Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened."

Did you solve this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment