Tracking visitors
...
despite Varnish
Who am I
Fabrizio Balliano
@fballiano
PHP since 1999
In Magento since 2007
magento.com/it admin
Full time Magento since 2011
CTO of Sevenlike S.r.l.
What is Varnish
Web application accelerator
HTTP reverse proxy
Cache server
Tremendous speed gain
Saves CPUs
Saves network traffic
Maybe full RAM solution
What is Varnis for Magento
Full Page Cache
- Pre rendered HTML pages
Static assets
- JS/CSSs
- Images
A sample infrastructure
Visitor path – page not in cache
Visitor path – page in cache
The problem is...
The web servers
never knows
about a visit
to a cached page
we track visitors other ways, yes?
Most modern tracking softwares
(actually services)
are javascript based
anyone said Google Analytics?
What about tracking visitors
INSIDE MAGENTO?
Customize browsing experience
based on visitor's behavior
Reports in the backend
What about this?
AND THIS?
And this?
But... if the frontend servers
are not getting ANY requests...
these features
(and any other tracking)
will not work
Cookies or localstorage?
Can we use them to have the "recently viewed" feature back?
Yes, it's ok, but not enogh in most cases.
It solves just part of the problem.
Let's GET BACK TO our jurney
notice anything here?
Dynamic blocks!
Types of Dynamic blocks
ESI: Edge Side Includes
- Not visible to client
-
Before page load
-
Can be cached
-
whole site/one page
-
each user/all
-
NO COOKIES!
- Little data transported
AJAX
-
Visible to client
-
After page load
-
Can NOT be cached
-
COOKIES!
-
A lot of data
Configuration reference
Let's add a new dynamic block!?
Hey, wait!
Every call to the frontend servers matters!
Can we reach our goal
without adding a new
ESI/AJAX dynamic block?
Flash messages!
PATCH THE CORE?
NO! IT'S NOT NECESSARY!
Flash messages: let's extend them
Flash messages: let's extend them
class Fballiano_TurpentineRecentlyViewed_Block_Messages extends Nexcessnet_Turpentine_Block_Core_Messages
{
public function _prepareLayout()
{
// code to do whatever we want
return parent::_prepareLayout();
}
}
THANK YOU!
Tracking visitors despite Varnish
By Fabrizio Balliano
Tracking visitors despite Varnish
If you've Varnish as your Full Page Cache provider you'll have great performance with some limitations. One of them is that your Magento backend servers will not know about your visitors' browsing paths (mostly). This presentation was created for the Meet Magento 2014 Poland.
- 1,792