felixdiazesc Posted February 3, 2022 Posted February 3, 2022 Site URL: https://www.felixdiazescauriaza.com Hello all! I'm using Flatiron template for my illustration portfolio, and my Squarespace 7.0 site is integrated with Google Analytics (UA property). By default, Google Analytics tracks the index page as a whole, but doesn't show each picture from the index's gallery individually, so a few years ago I looked for a solution that would make G Analytics trigger each time a single picture from the index gallery was selected. I found this great solution from Silvabokis (Colin Irwin) that consisted on inserting some CSS in the header of my Squarespace site, and it worked amazingly: each time someone selected a picture to display from the index gallery, Google Analytics counted it as a single page si I was able to see which of my illustrations was more clicked. This is the injected code: <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script> var initialhref = window.location.href; window.setInterval(foo, 1500); function foo(){ var currenthref = window.location.href; if ( currenthref != initialhref ) { var arrsplitvpv = currenthref.split('https://www.felixdiazescauriaza.com/'); var trackurl = arrsplitvpv[1]; var pagetitle = $("#grid .sqs-dynamic-data-active .project-title h2").text(); ga('send', 'pageview', '/vpv/' + trackurl, 'pagetitle'); initialhref = currenthref; }; } </script> It worked until recently. Now it doesn't trigger when anyone loads a particular picture from my index gallery. I understand some code but I'm really far from being able to touch it, so I don't know what's happening now... I recently changed my domain to felixdiazescauriaza.com, and I Donn't know if that has got something to do with it failing... I've updated Google Analytics to reflect the new URL, and also everything in Squarespace, etc... I'd appreciate it if someone could help me solve this or if there's another workaround to being able to track each individual picture from my Flatiron index in Google Analytics, please. Maybe switching to the new Squarespace 7.1? Also, all the credit to Colin Irwin at Silvabokis for the mentioned code. Thanks so much in advance! Felix Diaz de Escauriaza, freelance illustrator based in Madrid (Spain). Illustrated maps, editorial work and my online portfolio at felixdiazescauriaza.com
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment