Ramya
Ramya

Reputation: 1

Getting the text value of link when clicked a particular link in a page in adobe dtm rules

Using the source code below, I need to track text values of clicked links.
How can I track this and whether page load rule or event based rule is beneficiary for it?
How to code this using dtm?

<div class="afgfj">
<section class="asked-questions">
        <div class="g-bp-row-gutter p-comp-spacinottom p-rb">
            <h2 class="p-heading-02 p-component-title">
                Frequently Asked Questions
            </h2>
    <dl class="p-faq-main p-accordion"
                data-ctn="S9031/26">
                <dt class="p-top-10 p-faq-chapter p-active">
                      <span class="p-top-10-global">Top-10 FAQs</span>
                      <span class="p-top-10-local">Top 10 FAQs</span>
                </dt>
                <dd class="p-top-10 p-faq-list p-active">
                    <ul class="p-bullets">
                        <li class="p-faq-item" data-lang="ENG">
                                <div class="p-magnific-popup-launcher" data-comp-id="magnificPopupLauncher"
                                    data-type="iframe"
                                    data-title="Frequently asked questions"
                                    data-close-label="Back"
                                    data-href="//www.org.com/cgi-bin/oleeview?view=aa12_view_body.html&dct=QAD&refnr=0073544&slg=ENG&scy=GB&ctn=S9031/26">
                                    <a href="#">How long does it take to get?</a>
                                </div>
                              </li>
                     <li class="p-faq-item" data-lang="ENG">
                            <div class="p-magnific-popup-launcher" data-comp-id="magnificPopupLauncher"
                                    data-type="iframe"
                                    data-title="Frequently asked questions"
                                    data-close-label="Back"
                                    data-href="//www.org.com/cgi-bin/oleeview?view=aa12_view_body.html&dct=QAD&refnr=0020591&slg=ENG&scy=GB&ctn=S9031/26">
                                    <a href="#">Can I recharge the appliance?</a>
                                </div>
                              </li>

Upvotes: 0

Views: 1613

Answers (2)

David Leal
David Leal

Reputation: 1

I am assuming you are attempting to get the text of an <a> element when it is clicked on.

Such as in the one below, you would want to get "How long does it take to get?":

<a href="#">How long does it take to get?</a>

To do this, create an event based rule with the event type "click", set the element tag to "a". (See image below)

Conditions Setting

Next you will want to configure the Adobe Analytics section of the rule.

You will set the Tracking to s.tl() ,since you do not want to create a pageview when someone clicks the link (the page they view should already do that).

Then set an eVar and/or Prop to %this.text%. This is DTM notation to grab the text of the element that triggered the rule to fire.

Finally, set an event to trigger on this rule.

See image below for the configuration

Adobe Analytics configuration

This should track when an <a> element is clicked and store the text in an eVar

Upvotes: 0

Gary
Gary

Reputation: 111

This is a perfect time to use an Event Based Rule. You'll also need to create a data element to hold the text value.

The main obstacle that I can see from your code would be identifying the A tag correctly.

First the Data Element: in DTM Rules, within Data Elements click Create New Data Element.

enter image description here

Enter a name, specify the type (CSS Selector seems the most appropriate here) then within the CSS Selector Chain list state how to reach it. My guess is for your code it would be "div.p-magnific-popup-launcher a" but you would need to test this. You can tell by opening a Inspect Element (F12) in Chrome or similar debugging gadget. There's a good blog about doing this from Adobe here.

You should also specify which part of the A tag to save. From your question you I believe you need 'text' which would capture items like "How long does it take to get?"

Under Event Based Rules within DTM click Create New Rule.

When you're happy with the settings on this page click Save Data Element.

enter image description here

Populate your name, and category if applicable. The Event Type should already be set to 'click'.

Within Tag you then have to set how to find the A tag through CSS, similar to above.

That's the basics, but you'll also need to set Criteria (what pages this should fire on). Furthermore, under the Adobe Analytics section you should set whether a pageview is incremented or not, and which eVars, Props and Events are populated as a result of the click. This is also where you can use the value from your Data Element. Under Link Tracking, choose Custom Link. Within Link Name, enter a percent sign (%) and your data elements should appear. Use the name you specified earlier.

Note: you should match up your populated eVars and Events etc. with your settings under Report Suites in the Analytics interface.

Upvotes: 1

Related Questions