Mobile app version of vmapp.org
Login or Join

Login to follow query

More posts by @Murphy175

1 Comments

Sorted by latest first Latest Oldest Best

 

@Alves908

The script would work with some tweaking, the only change would be setting 'custom dimensions' instead of variables.

However, a more elegant solution would be this tag manager implementation which lets you filter by session to view a single users funnel.

Not great for big data but lets you pull case studies.

Edit: I went ahead and tested the Tag Manager method:


Create a custom HTML tag, insert this script:



<script>
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1);
if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
}
return "";
}
if (!getCookie("firstTouch"))
{document.cookie = "firstTouch=" + window.location.pathname;}
</script>






Add cookie variable

Create a custom dimension in Analytics





You can send the custom dimension in all your pageviews (optimal), or to test it you can put the variable into an event label. This will appear in 'Real Time' events then for you to check immediately:




If you wanted a pure javascript version, then you can edit your push to include firstTouch in the custom dimension like this:

> <script> function getCookie(cname) {
> var name = cname + "=";
> var ca = document.cookie.split(';');
> for(var i=0; i<ca.length; i++) {
> var c = ca[i];
> while (c.charAt(0)==' ') c = c.substring(1);
> if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
> }
> return ""; } if (getCookie("firstTouch"))
> {var firstTouch = getCookie("firstTouch"));}
> else {document.cookie = "firstTouch=" +
> window.location.pathname;} ga('set', 'dimension1', firstTouch);
> </script>

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme