FoxInCloud
Google analytics
Hi Thierry,
The following code must be inserted right after the <head>
tag
<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'GA_TRACKING_ID');
</script>
.cScriptJSAdd_ ()
inserts at the end. What is the best way to insert this code in the right place?
As this is HTML, .cScriptJSAdd*()
can't be used
IMO it should come right before </body>
after the other <script>
tags
Where do you read it should be right after the <head> tag
?
In google documentation.
Here: https://support.google.com/analytics/answer/1008080?hl=fr
There is nothing specific for that, however this should work (replace <
by <
):
modify command xxxServer
define class xxxProcess
…
&& add this:
* ------------------------------------------------------------
protected function wFormStandardPage_cMetaTagsAdd && {en} additional meta tags for your standard page
&& {en} Implement / override in your subclass xxxProcess
&& {fr} Implementez / surchargez dans votre sous-classe xxxProcess
local lcHTML, GA_TRACKING_ID
GA_TRACKING_ID = "… your site key …"
text to lcHTML textmerge noshow flag 1
<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<<GA_TRACKING_ID>>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<<GA_TRACKING_ID>>');
</script>
endtext
return m.lcHTML
encfunc
lcHTML = '';
+ "<!-- Global Site Tag (gtag.js) - Google Analytics -->" + CRLF;
+ [<script async src="https://www.googletagmanager.com/gtag/js?id=] + GA_TRACKING_ID + ["></script>] + CRLF;
+ …
not better. I commented on my code for a new update
what do you mean? What error? This is unclear
I tried this code, without success:
PROTECTED FUNCTION wFormStandardPage_cMetaTagsAdd && {en} additional meta tags for your standard page
&& {en} Implement / override in your subclass xxxProcess
&& {fr} Implementez / surchargez dans votre sous-classe xxxProcess
LOCAL lcHTML, GA_TRACKING_ID
GA_TRACKING_ID = "U ... "
TEXT TO lcHTML TEXTMERGE NOSHOW FLAGS 1
<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<<GA_TRACKING_ID>>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<<GA_TRACKING_ID>>');
</script>
ENDTEXT
RETURN CHR(0) + m.lcHTML
ENDFUNC