PDA

View Full Version : Google Analytics code integration



Mike
September 22, 2009, 12:57 PM
Hi all,
I want to show how you can integrate the Google Analytics code to your site.
Here the full instruction:
- Create new Google Analytics account and get javascript code for integration. (https://www.google.com/analytics)
- Find and open following file:
/templates/CURRENT_TEMPLATE/tpl/footer.tpl
- find following tag:


</body>

and add the Google Analytics javascript code before tag,
also do not forget to place the following code line before Google code:

{literal}
and the following after Google code:

{/literal}
- save changes and close the file

Then you should wait about 5-10 hours while Google detect javascript code in your site.
Please ask your questions here if you have some problems with integrations.

Murat Altun
August 13, 2010, 01:00 PM
Hello Mike,

wonderful, it works perfect! :D

Thanks and regards,

Thomas

Jeff
March 23, 2012, 12:50 PM
Just a quick update for anyone -- like me -- who stumbles upon this post. Google now recommends installing Analytics in the header, just before the </head> tag. So for best results, take everything that Mike F. said up above, and just move your Analytics code to the header.

Hemal Ruparelia
July 27, 2012, 05:15 PM
Hi guys.

I can't find the </head> tag in footer.tpl. Should I follow the original instructions or am I looking in the wrong file or am I missing something?

Thanks,

Hemal

Chris Brown
July 27, 2012, 06:01 PM
Hi guys.

I can't find the </head> tag in footer.tpl. Should I follow the original instructions or am I looking in the wrong file or am I missing something?

Thanks,

Hemal

</head> tag is in the header.tpl file

Hemal Ruparelia
July 28, 2012, 02:27 AM
Thanks mate. Yeah I would have thought that would be the logical choice and had a look there (looked again after reading your post).

But all I see in my header file is this:


{if $smarty.const.RL_LANG_DIR == 'rtl'} {assign var='text_dir' value='right'} {assign var='text_dir_rev' value='left'} {else} {assign var='text_dir' value='left'} {assign var='text_dir_rev' value='right'} {/if} {if $rss} {/if} {include file='js_config.tpl'} {rlHook name='tplHeader'} {$ajaxJavascripts}
{include file='blocks'|cat:$smarty.const.RL_DS|cat:'lang_se lector.tpl'}


{$lang.slogan_large}
{assign var='slogan' value=' '|explode:$lang.slogan_small} {foreach from=$slogan item='slogan_word' name='slogan'} {if $smarty.foreach.slogan.last} {$slogan_word} {else} {$slogan_word} {/if} {/foreach}
{include file='menus'|cat:$smarty.const.RL_DS|cat:'main_men u.tpl'}

I am a bit of a nooby so I might be missing something very obvious here.

Any ideas?

Again, the help is much appreciated.

Thanks

Chris Brown
July 28, 2012, 08:05 AM
hmmm mines in the header.tpl ......what version software do u use and which template?

Hemal Ruparelia
July 29, 2012, 03:37 AM
I use the realty spring (The latest version of Flynax)

Cammie Bradford
July 29, 2012, 09:24 AM
Hi Hemal,

are you sure? I have had a look in the header.tpl of reality spring and found there the head tags without problems. Have you had a look in the correct tpl - file? You will find it in this folder:

/templates/yourtemplate/tpl

There you have to open the header.tpl file.

Best regards,

Cammie

Hemal Ruparelia
July 29, 2012, 04:40 PM
Hey thanks Cammie,

That is the file I am looking at and this is verbatim what is on the header.tpl file:

{if $smarty.const.RL_LANG_DIR == 'rtl'} {assign var='text_dir' value='right'} {assign var='text_dir_rev' value='left'} {else} {assign var='text_dir' value='left'} {assign var='text_dir_rev' value='right'} {/if} {if $rss} {/if} {include file='js_config.tpl'} {rlHook name='tplHeader'} {$ajaxJavascripts}
{if $pageInfo.Key == 'home'} {include file='header_home.tpl'} {else} {include file='header_main.tpl'} {/if}

Think I might have to submit a ticket...

Thanks heaps anyway and let me know if you get any other ideas.

Viktor
July 30, 2012, 03:08 AM
Hello Helman,

If you are not sure you can create a ticket with your request of curse. We will solve it ASAP.

Hemal Ruparelia
July 30, 2012, 03:19 AM
Thanks Viktor,

Have done so.

Hemal

Curtis
August 21, 2012, 12:11 PM
Hey thanks Cammie,

That is the file I am looking at and this is verbatim what is on the header.tpl file:

{if $smarty.const.RL_LANG_DIR == 'rtl'} {assign var='text_dir' value='right'} {assign var='text_dir_rev' value='left'} {else} {assign var='text_dir' value='left'} {assign var='text_dir_rev' value='right'} {/if} {if $rss} {/if} {include file='js_config.tpl'} {rlHook name='tplHeader'} {$ajaxJavascripts}
{if $pageInfo.Key == 'home'} {include file='header_home.tpl'} {else} {include file='header_main.tpl'} {/if}

Think I might have to submit a ticket...

Thanks heaps anyway and let me know if you get any other ideas.

Hello Hemal,

You can try insert the Google code (as Mike told) after a code which you showed here. Thanks

Morgan Bohman
August 21, 2012, 01:18 PM
To insert your analytics code, go to /templates/your-template/tpl/footer.tpl. Find the line
{rlHook name='tplFooter'} around line 19. Insert after that line your code like this
{literal}
<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'XX-accountid-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>
{/literal}
This works like a charm, good luck!

//Morgan

Mohammed Kiswani
August 28, 2012, 12:15 PM
Hi, how can i add google analytics to my hosted software


Hi all,
I want to show how you can integrate the Google Analytics code to your site.
Here the full instruction:
- Create new Google Analytics account and get javascript code for integration. (https://www.google.com/analytics)
- Find and open following file:
/templates/CURRENT_TEMPLATE/tpl/footer.tpl
- find following tag:


</body>

and add the Google Analytics javascript code before tag,
also do not forget to place the following code line before Google code:

{literal}
and the following after Google code:

{/literal}
- save changes and close the file

Then you should wait about 5-10 hours while Google detect javascript code in your site.
Please ask your questions here if you have some problems with integrations.

Morgan Bohman
August 28, 2012, 12:32 PM
If you have ftp login to the site, just follow the procedure above. If not file a ticket.

Mike
August 29, 2012, 03:21 AM
Morgan right,
You as hosted license owner should have access to the templates directory - its enough to paste the code.

Mike
April 24, 2013, 03:42 AM
For those who are looking how is better to add Google Analytics or other code:

We have plugin for convenient 3rd party codes management - it's <a href="http://www.flynax.com/plugins/verificationcode.html">Verification Code</a> plugin

Jahid Zaynal
July 19, 2014, 01:05 PM
I've done so and it looks like it SHOULD work. but when I log in to my Analytics account, it says "Tracking code not installed". I know your post says wait 5-10 hours, but it says on Google Analytics that it was last checked only a few seconds ago. then how come it doesn't detect it?

Note: I can see the javascript code in my web page when I look at the html code output to the browser.

Alejandro andres Donato
July 8, 2016, 12:03 AM
Hi to all, maby can help me, because I use the Vertification code for first time, and I get the code from google analytics page. So I installed the plugin, and then I did go to the veritication code plugin, then I click on add a code, then set the name: Google_analytics . in the position I select footer, and then I only paste this code:

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-80443024-1', 'auto');
ga('send', 'pageview');

</script>

Just that nothing else. And I leave checked sticky, however It past about 10 hours, and I don't see any page view in the analytics google page, Only the traffic test worked fine ( one visited ) but nothing else.
some one know what to do?

Wei Hong
July 8, 2016, 04:59 AM
Can you try header instead of footer. I picked header and it works fine. The code looks fine to me

Alejandro andres Donato
July 8, 2016, 02:47 PM
Hi to all.

For fix that problem I leave the Verification plugin enabled.

And I edit the tpl/footer.tpl and I add



{literal}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-80443024-1', 'auto');
ga('send', 'pageview');

</script>
{/literal}


Now the google analytics works fine... without any problem.
I don't know why, but maby the plugin it's not working fine.
I din't try to put the plugin in the header position.

I just edit that file, and a few hours later the code worked fine for me.
Also I leave the plugin with that code enabled.

Gen82
June 26, 2019, 11:10 AM
Hello , have problem with google analytics on flynax version 4.7.2 , google only finde subdirectory /blog not the flynax script. is that new rules of indexing from google and should remove the code from subdirectory or??

Gen82
June 26, 2019, 11:43 AM
Alejandro andres Donato this code from you work properly olso to my version of the flynax 4.7.2