Hello,
My client uses virtual page views in Google Analytics to track user behavior on their website. A click leading to a product page is tracked differently depending on whether the click happens in the search results, popular products sidebar, or featured items sidebar. This is accomplished with an ONCLICK event for the thumbnail and text links.
However I hit the limits of my programming abilities when it comes time to add the tracking to the ADD TO CART button in such a way that it is known what context the item is added from (sidebar, search results, product page, etc).
I can add the ONCLICK event to the user control, but I want to be able to pass the context to the tracking code. So the virtual page view could be named like, "add-to-cart_Popular-Products," or, "add-to-cart_Product-Page."
The scriptlet name seems like a simple enough context identifier, but I'm open to suggestions by those with more experience.
So my question is- how can I get the name of the calling scriptlet from within the add-to-cart user control (or a similar context identifier that lets me know where on the page the button was clicked)?
Thanks!
context (parent scriptlet) for addToCart user control?
- crockettdunn
- Lieutenant Commander (LCDR)
- Posts: 105
- Joined: Sun Oct 26, 2008 6:32 pm
- Contact:
- crockettdunn
- Lieutenant Commander (LCDR)
- Posts: 105
- Joined: Sun Oct 26, 2008 6:32 pm
- Contact:
Re: context (parent scriptlet) for addToCart user control?
Here is what I came up with, in AddToCartLink.aspx:
<%=this.Parent.Parent.NamingContainer%>
shows nothing for a product page, and for the respective conlib controls, returns:
ASP.conlib_custom_popularproductsdialog_ascx
ASP.conlib_custom_alsobought_ascx
ASP.conlib_custom_categorygridpage_ascx
I'm assuming this is sloppy/hackish, and it's just luck that these happen to all be two levels (parent.parent) up. But hopefully this shows what I'm trying to do so someone can point me in the right direction.
<%=this.Parent.Parent.NamingContainer%>
shows nothing for a product page, and for the respective conlib controls, returns:
ASP.conlib_custom_popularproductsdialog_ascx
ASP.conlib_custom_alsobought_ascx
ASP.conlib_custom_categorygridpage_ascx
I'm assuming this is sloppy/hackish, and it's just luck that these happen to all be two levels (parent.parent) up. But hopefully this shows what I'm trying to do so someone can point me in the right direction.
- crockettdunn
- Lieutenant Commander (LCDR)
- Posts: 105
- Joined: Sun Oct 26, 2008 6:32 pm
- Contact:
Re: context (parent scriptlet) for addToCart user control?
meh... the above would get me the info within the server-side scope, which isn't super-convenient for passing to client-side script for Google Analytics. I'm going to use jQuery instead.