Can't link to anchors from emails

Anonymous
Not applicable

Can't link to anchors from emails

Apologies if this has been covered somewhere and I can't find it.  I am trying to add a link in a Marketo email that looks like this:  http://www.foo.com/page.html#someSection

My obvious intention is that the link will go to page.html and skip down to the paragraph id called #someSection.

But when I add this from the marketo email, marketo appends a long query string to the end of the url like this:

http://www.foo.com/page.html#someSection?mkt_tok=eyJpIjoiT0RRMFlURmlPRGd4WTJZeSIsInQiOiJpQ0lhNUp5ell...

This breaks the anchor tag and the scrolling I'm looking for doesn't happen.  The reason is that anchor tags should go after query strings, like this:

http://www.foo.com/page.html?mkt_tok=eyJpIjoiT0RRMFlURmlPRGd4WTJZeSIsInQiOiJpQ0lhNUp5ellZeFlZZE5Rd0N...

I'm certain there must be some workaround for this.  Help is appreciated.

Many thanks!

24 REPLIES 24
Nicholas_Manojl
Level 9

Re: Can't link to anchors from emails

Easy one:

Uncheck the bottom two boxes.

pastedImage_0.png

But in my experience not all email clients will respect the anchor links.

Justin_Cooperm2
Level 10

Re: Can't link to anchors from emails

Just uncheck "include mkt_tok" no need to make it untracked

Anonymous
Not applicable

Re: Can't link to anchors from emails

Thanks so much! Just to be sure, if I don't include the marketo token, will marketo still track the click-thrus?

Thank you!

Justin_Cooperm2
Level 10

Re: Can't link to anchors from emails

yes

SanfordWhiteman
Level 10 - Community Moderator

Re: Can't link to anchors from emails

Amy, weigh this decision carefully.  When you turn off automatic mkt_tok-enization but leave tracking on, you will get the Clicked Email events tied to the email, but you will not get subsequent web activities (Visit Web Page and Clicked Link in Web Page) because leads will be anonymous on your website.  This is a major tradeoff.   It's akin to having all your email links be direct links to PDFs, which similarly can't associate web sessions -- a practice to be avoided.

IMO, given this choice, I would rather get the web activities, since you can reverse-engineer the Clicked Emails from the Visits. (Email performance reports will be affected, yes, but the click target itself can be detected from the web side.)  You can get the web activities by turning off tracking in the editor, but then manually adding ##MKT_TOK## to the link: http://example.com/mypage?mkt_tok=##MKT_TOK###hashtag.

But you really aren't faced with this choice. If you want to scroll to a specific ID on the page, simply pass the ID in the query string, not in the hash (&openTo=someSection). Then use this very easy JS:

<script>

  document.getElementById(getURLParameter('openTo')).scrollIntoView();

/**

* @see [IOWA Util]

*/

function getURLParameter(param) {

    if (!window.location.search) {

        return;

    }

    var m = new RegExp(param + '=([^&]*)').exec(window.location.search.substring(1));

    if (!m) {

        return;

    }

    return decodeURIComponent(m[1]);

}

</script>

Stijn_Heijthuij
Level 7

Re: Can't link to anchors from emails

To confirm; if you add the ?mkt_tok= query parameter, Marketo will still add in the same query parameter somewhere else in the URL?

i.e.

www.google.com/?q=myquestion#answer1?mkt_tok=123

turns into

www.google.com/?q=myquestion?mkt_tok=123#answer1?mkt_tok=123

SanfordWhiteman
Level 10 - Community Moderator

Re: Can't link to anchors from emails

Yes, it will be redundantly added if you don't turn off mkt_tok formally.

I would use my other method anyway.  Too much confusion if some emails track clicks and others don't.

DeniseGreenberg
Level 4

Re: Can't link to anchors from emails

Hi @SanfordWhiteman  - I know this is a very old post but I don't see anything newer about it in the community.

 

If I understand you, you are saying instead of :

 

https://www.mywebsite.com#target-section/

 

To use:

https://www.mywebsite.com/?openTo=target-section

 

And then use the JavaScript you provided to get them to the desired section. So would the JavaScript go on the web page? If so, does it matter where on the page? As you know, this isn't my area of expertise.

 

Denise

 

 

Jo_Pitts1
Level 10 - Community Advisor

Re: Can't link to anchors from emails

@DeniseGreenberg ,

I'm not @SanfordWhiteman , but yes - that is exactly what he's saying.

I'd put the <script> at the bottom of the page, to make sure the anchor you want to scroll into view has been rendered.  Not sure how important that is, but it feels likely 🙂