Keyword
Please note that official support for commercial extensions & templates is provided in the Subscriber Help Desk.
Support requests should ONLY be directed there and require an active subscription plan.
This forum board is to be used for archive purposes and knowledge exchange ONLY.

[HACK] Adding Google Analytics event tracking to clicks in FPSS

  • vinny carvalho
  • vinny carvalho's Avatar Topic Author
  • Offline
  • New Member
More
11 years 8 months ago - 11 years 5 months ago #50030 by vinny carvalho
Love FPSS (version 3.2.0 ) (Joomla 1.5)– But one thing I have always wanted was for the ability to track when people click a slide that links to a document or website using google analytics 'events'.  I looked around and seems there was no built-in way to do this or any success by other users - so I tried what I guess would be called a 'hack' of the fpss code ( I am by no means a coder and do not wish to insult the developer).  Maybe this could be worked into the next version?
Using the JJ-Obs template as an example.
In the modules folder of the Joomla installation is the mod_ fpss folder - within that folder are all the templates.  Within the main folder for each template is a php file.  default.php

At or about line 20 you should see
<a<?php echo $slide->target; ?> href="<?php echo $slide->link; ?>" class="slide-link">

If you add your google onclick event code right after the initial <a tag it will now track the ‘event’ and it appears within google analytics
<a onclick="_gaq.push(['_trackEvent', 'LINK-EXTERNAL', 'LINK-EXTERNAL', 'LINK-CASE-STUDIES-<?php echo $slide->title; ?>']);"<?php echo $slide->target; ?> href="<?php echo $slide->link; ?>" class="slide-link">

In the above example the final event label in google analytics would be unique and read
LINK-CASE-STUDIES-followed by the title that I have given the slide within fpss itself.

Please Log in or Create an account to join the conversation.

More
10 years 10 months ago #50031 by Greg
I track mine in campaigns rather than events.  If you add ?utm_campaign=campaignname&utm_medium=mediumname&utm_source=sourcename (replacing campaignname, mediumname & sourcename with your desired values) to the end of your links they are tracked in GA without the hack.  You only have to use a custom url in the fpss slide instead of joomla article or menu item.  See screenshot attached.
Attachments:

Please Log in or Create an account to join the conversation.

More
6 years 2 months ago - 6 years 2 months ago #166446 by natecovington
I had to figure this out recently for a client using Joomla 3.8.x and K2 2.8, with the newer Universal Analytics tracking method. Here is my "onClick" command that also sends the attachment filename and title to Analytics...
onclick="ga('send', 'event', 'PDF', 'Download', '<?php echo $attachment->filename; ?> <?php echo $attachment->title; ?>');"

Edit: Whoops, was trying to post this under a relevant K2 forum topic, didn't realise this was for FPSS.
Last edit: 6 years 2 months ago by natecovington. Reason: wrong topic

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 2 months ago #166451 by Krikor Boghossian
No worries :)
You can post it again.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum