Integrating with Google Tag Manager

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Integrating with Google Tag Manager

apnadkarni
Wanted to integrate a Google Tag Manager snippet with my asciidoctor generated output. As per the GTM docs, their snippet should be placed right after the <body> tag in the html but I cannot figure out how to get that to happen. Placing it at the top of the file gives me an error "only book doctypes can contain level 0 sections".

Any hints?

Thanks in advance

/Ashok
Reply | Threaded
Open this post in threaded view
|

Re: Integrating with Google Tag Manager

mojavelinux
Administrator
Ashok,

Integrations such as these are best done using either the docinfo feature or a custom document template. You'd pass metadata, such as a list of tag names, using one or more AsciiDoc attributes.

This section explains how to use the docinfo feature: http://asciidoctor.org/docs/user-manual/#docinfo-file

To create a custom document template, create a new folder, copy one of the html5 document templates (e.g. document.html.haml) from https://github.com/asciidoctor/asciidoctor-backends to that folder and specify the folder when invoking the asciidoctor command:

 $ asciidoctor -T my-templates file.adoc

But I'd try the docinfo approach first.

Another option is to create a custom extension (DocinfoProcessor or Postprocessor). We do something similar for Google Analytics. See https://github.com/asciidoctor/asciidoctor-extensions-lab/blob/master/lib/google-analytics-postprocessor.rb

Cheers,

-Dan

On Wed, May 6, 2015 at 5:24 AM, apnadkarni [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Wanted to integrate a Google Tag Manager snippet with my asciidoctor generated output. As per the GTM docs, their snippet should be placed right after the <body> tag in the html but I cannot figure out how to get that to happen. Placing it at the top of the file gives me an error "only book doctypes can contain level 0 sections".

Any hints?

Thanks in advance

/Ashok


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Integrating-with-Google-Tag-Manager-tp3128.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Reply | Threaded
Open this post in threaded view
|

Re: Integrating with Google Tag Manager

apnadkarni
Dan,

Thanks for your response. I'd already tried the docinfo method but that put the snippet in the <head> section, not the <body>. I'll try your other suggestions.

/Ashok
Reply | Threaded
Open this post in threaded view
|

Re: Integrating with Google Tag Manager

mojavelinux
Administrator

It seems odd that the snippet goes in the body, but maybe I'm misunderstanding what the snippet is. Is it content?

Another option is a pass block, though it's usually best to avoid those. Postprocessor might be your best choice.

-Dan

Le 7 mai 2015 4:41 AM, "apnadkarni [via Asciidoctor :: Discussion]" <[hidden email]> a écrit :
Dan,

Thanks for your response. I'd already tried the docinfo method but that put the snippet in the <head> section, not the <body>. I'll try your other suggestions.

/Ashok


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Integrating-with-Google-Tag-Manager-tp3128p3134.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: Integrating with Google Tag Manager

apnadkarni
Yes, it's odd. I think it's because along with the javascript, the GTM snipprt also has an iframe  for non-javascript-enabled browsers. There is a blog on the rationale for putting it at the top of the body but I can't find the link now.

/Ashok
Reply | Threaded
Open this post in threaded view
|

Re: Integrating with Google Tag Manager

mojavelinux
Administrator

On Thu, May 7, 2015 at 8:40 PM, apnadkarni [via Asciidoctor :: Discussion] <[hidden email]> wrote:
, the GTM snipprt also has an iframe

That makes sense.