Question

Google Analytics on K2 based web site

  • 25 May 2016
  • 3 replies
  • 399 views

Hi All,

 

Our client is curious to know if we can use Google Analytics on their website.

 

Backgroud:

 

This website is a total K2 based solution. No SharePoint used. Form, workflow - everything is in K2 Blackpearl 4.6. No code has been written. Just used out of the box K2 functionalities. 

 

In this scenario, can someone guide me if it is possible to use Google Analytics? If so, any pointers?

 

Thanks so much for your guidance! 


3 replies

So I did some more research and looks like if i include the Google analytics JavaScript code into my smartform, it should do the required. 

 

has anyone tried doing this? 

This is actually a task for my current employer. The question here is do you want analytics for all smart forms or just particular forms?

If particular forms, you could always use the datalabelcontrol set to literal trick for injecting javascript into a page.

 

However, if you want to collect analytics for all forms you need to get more drastic to set things up in a way that is maintainable. I created a POC for this approach using PiWik and worked like a charm.

 

DISCLAIMER: This approach you are modifying K2 delivered code and will be stepped on during upgrades. Use at your own risk.

 

To inject the javascript for use for ALL forms in your setup. Go to the K2 Server, locate the runtime website usually located at C:Program Files (x86)K2 blackpearlK2 smartforms Runtime (or whatever your install directory is for K2 for those of you that like to use the D drive.)

 

From this folder, locate the "Runtime" folder and look for a file called form.aspx. You can then inject your Google (or other analytics) script at the end of the mark up in this file. This will enable analytics for all forms. You can also inject this script into view.aspx to catch any subviews that are opened as well.

 

As always, take standard precautions before modifying this file. Make a backup and put it in a safe location and don't tinker with any of the other markup in the file. If you stick to plan and put your code in the right spot it should light up analytics for all forms.

 

Hope this helps.

 

S.

Badge +13

Hi,

 

Is anyone able to say exactly what the structure of the code you enter in the forms.aspx file looks like?

 

Also, if you wanted to do this on a Form by form basis only, where and how to you insert the Google analytics code?

 

Thanks

Reply