Chartbeat Tracking Code

Rate this topic: Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.1.00 out of 6 based on 1 vote(s)
GK User
Wed Oct 05, 2016 8:34 pm
Reply with quote
Report this post
We want to implement Chartbeat web analytics tracking code which consists of 2 javascipt snippets.
One is to be placed before the </head> tag and the other to be placed before the </body> tag.
Can you clarify a few questions for me?
1. I think the path to the file I need is libraries/joomla/document/html/renderer/head.php - can you confirm this is the correct file?
2. Can the script be placed "as is" inside the <head></head> or does it need to be converted to a php function?
If it can be placed 'as is' can you suggest where exactly we should place it so it functions as a standalone?
3. Can you suggest the file where the second snippet can be placed permanently before the </body> tag?
Here is a link to the Charbeat documentation: http://support.chartbeat.com/docs/
Thanks.
User avatar
Senior Boarder

teitbite
Thu Oct 06, 2016 11:09 am
Reply with quote
Report this post
Hi

No it's not correct file.

Part of the code which should go between <head></head> needs to go to /layout/block/head.php in template.

Part of the code before ending body tag </body> needs to go to /layout/default.php look at the bottom of this file.
User avatar
Moderator

GK User
Thu Oct 06, 2016 9:06 pm
Reply with quote
Report this post
Can the script be placed as supplied with its script tags in these documents?
User avatar
Senior Boarder

teitbite
Fri Oct 07, 2016 1:46 pm
Reply with quote
Report this post
Hi

Do not know how this script looks like, but I believe so. You may just need to close/open PHP tags, so it will not appear as a part of PHP code.
User avatar
Moderator

GK User
Tue Oct 11, 2016 7:11 pm
Reply with quote
Report this post
This helps, thanks.
Can you also please tell me how to find the template variables that contain the author and section for the articles?
User avatar
Senior Boarder

teitbite
Wed Oct 12, 2016 12:32 pm
Reply with quote
Report this post
Hi

I'm afraid I do not understand what do You mean by article section. Author is shown from joomla directly and can be changed in user settings.
User avatar
Moderator

GK User
Wed Oct 12, 2016 6:07 pm
Reply with quote
Report this post
Sorry I did not explain well.
The script placed before the closing body tag requires values to be sent to Chartbeat for both section and author. I understand that these are set during the creation of each article but since this code, if placed in the /layout/default.php, will require dynamic population, I wondered if there was a page-level variable that contained this information.
If not then the script would have to be placed at the bottom of each article and populated manually.
My worry with this method is that it would not end up appearing directly before the closing body tag, but merely at the end of the article. This is highly recommended by Chartbeat in order not to slow down the site.
I really appreciate your help with this and their instructions can be found here, together with the code snippets. http://support.chartbeat.com/docs/
User avatar
Senior Boarder

teitbite
Thu Oct 13, 2016 4:24 pm
Reply with quote
Report this post
Hi

The only place such informations are sheared are in component layer. Which means will be best to put this code to /html/com_k2/templates/default/item.php or /html/com_content/article/default.php depending if You are using joomla articles or k2. Also I think You can leave part of this code in /layout/default.php and only use this lines:

Code: Select all
<script type='text/javascript'>
    _sf_async_config.sections = 'Change this to your Section name'; //CHANGE THIS
    _sf_async_config.authors = 'Change this to your Author name'; //CHANGE THIS
</script>


BUT

if this needs to work, You will also need to move line:

Code: Select all
<script type='text/javascript'>
    var _sf_async_config = _sf_async_config || {};
</script>


right after <body> opening tag.
User avatar
Moderator


cron