Comments (3)
This is possible, but you'll have to add a bit of code to make it work.
What you want to look at is the hitFilter
option, which allows you to programmatically modify any hit prior to it being sent, and in the case of hits that are the result of user interaction with a DOM element, that element gets passed to the function as well.
Here's a basic example of how you could do what you're asking (note: you might have to modify it to work with your setup):
ga('require', 'eventTracker', {
hitFilter: function(model, element) {
// Only sets the event label as the link `href` for clicks on elements
// with an `href` property.
if (element.href) {
// Make sure to set the third parameter to `true` so this value only
// gets sent with the current hit.
// https://developers.google.com/analytics/devguides/collection/analyticsjs/model-object-reference#set
model.set('eventLabel', element.href, true);
}
}
});
from autotrack.
One issue I am seeing is
when I console.log, element in hitFilter, I get
It doesn't return all the links under the div or unable to find which link is actually clicked.
Options for me are
Add all the link in above div into event listeners and check if link is clicked and add use that in hitFilter.
I am doing this on different div's
eg. is
<div class="xyz" data-on="click" data-event-category="blog" data-event-action="click">
<div class="col-md-12">
<h3 class="text-primary today BlogListHeader">Blog & News</h3>
</div>
<div class="BlogList">
<div class="col-md-12">
<div class="row">
<div class="blogitem">
<div class="col-xs-4 col-md-5">
<a href="http://test.com.au/"><img class="img-responsive" src="seating_74ced3b40ec351b7700e96378f870fa1_w320_r1.6.jpg" alt="" /></a>
</div>
<div class="col-xs-8 col-md-7 no-pd-lft">
<div class="headline">
<b><a href="http://test.com.au/">A Look Inside</a></b>
</div>
<div class="description">What you can expect from the renowned Airlines</div>
</div>
</div>
</div>
from autotrack.
The element
variable isn't going to reference the links within the div because you put the data-*
attributes on the div itself. The eventTracker
plugin isn't specific to links, it can be used with any type of element.
from autotrack.
Related Issues (20)
- urlChangeTracker does not work HOT 1
- /
- hover event for eventTracker?
- Move dependencies to devDependencies HOT 1
- Is this the way to implement stepped scroll tracking?
- command not found: autotrack HOT 2
- cleanUrlTracker temperamental
- Twitter restablecer
- Support for VueJS and NuxtJS?
- Ecommerce Plugin
- hash tracker
- Library no longer maintained - what now? HOT 2
- Fff
- Send custom metrics with autotracking?
- Test
- Google analytics tracking doesn't require URL request to track a local R Shiny app HOT 1
- Failed to execute 'unobserve' on 'IntersectionObserver': parameter 1 is not of type 'Element'.
- Ahmed X
- Xx
- isssue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from autotrack.