0

please help. I have a landing page, with direct links in body to my store. I want to run specific link with analytics script in iframe, only to collect statistics from users who clicked link

<a href="www.myshop.com">link</a>

How can I do this?

Vladimir
  • 51
  • 2
  • Sorry, I unintentionally deleted the correct duplicate comment: [Open-link-in-new-tab-or-window](https://stackoverflow.com/questions/15551779/open-link-in-new-tab-or-window) – Rene May 04 '20 at 06:58

1 Answers1

0

Reference: open-link-in-new-tab-or-window

This could work for you:

$('a').click(function(e){
    e.preventDefault();
    var href = this.href;       
    console.log('go to the other page or highlight on the same page');
    location.href = href;
});
#demo {
width: 75%;
margin: 0 auto;
background-color: #fff;
-webkit-transition: all 1s linear;
}

#demo:target {
background-color: #ffa;
-webkit-transition: all 0.2s linear;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<a href="#demo">Link to a demo</a>
<div id="demo">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>

Code is based on the example of the accepted answer of this post: Highlight target

Rene
  • 976
  • 1
  • 13
  • 25
  • Can I do this in the same window? – Vladimir May 04 '20 at 06:44
  • @Vladimir What do you mean with same Window? Do you want to know, if you can use the function "click" in the same window or do you want to link to a section of the window? – Rene May 04 '20 at 06:54
  • @Vladimir Yes, you can do it in the same Window. I've edited the answer based on your question in the comment. – Rene May 05 '20 at 10:37
  • @Vladimir Was my answer correct or at least helpful for you? – Rene Jun 15 '20 at 12:36