Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Condition based on data-target selector?

Avatar

Avatar
Validate 1
Level 1
richm92841132
Level 1

Likes

3 likes

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 1
richm92841132
Level 1

Likes

3 likes

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
richm92841132
Level 1

08-08-2018

I want to fire a rule when someone clicks on the Accessories link (see screenshot below). There is no specific class or ID i can use (each page is using a different ID for the same link) but, if I could trigger the rule based on the data-target="#accessories" selector, it should work. Any idea on how to do this?

Screenshot 2018-08-08 14.07.27.png

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Give Back
Level 2
AnalyticsAlice
Level 2

Likes

10 likes

Total Posts

10 posts

Correct Reply

7 solutions
Top badges earned
Give Back
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Give Back
Level 2
AnalyticsAlice
Level 2

Likes

10 likes

Total Posts

10 posts

Correct Reply

7 solutions
Top badges earned
Give Back
Boost 5
Boost 3
Boost 10
Boost 1
View profile
AnalyticsAlice
Level 2

09-08-2018

Hi richm,

The basic selector you'd need to broadly target all links with data-target="#accessories":

a[data-target='#accessories']

If there are other links on the page using that data-attribute and you want to exclude them from your rule, you can leverage the parent div with ID #recommendations and other classes assigned to parent elements to make the selector more specific to that section, for example:

div#recommendations ul li a[data-target='#accessories']

Answers (1)

Answers (1)

Avatar

Avatar
Validate 1
Level 1
richm92841132
Level 1

Likes

3 likes

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 1
richm92841132
Level 1

Likes

3 likes

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
richm92841132
Level 1

09-08-2018

Perfect, thanks AnalyticsAlice!

-Rich