How to track URL source? - url

I have in my website "See More" link, what do I need to add to the link in order to see or count how many people using the "See More" link (with google analytics). This link is custom and unique per post. Is there any UTM parameter that I need to add?

You can add an event tracker to track when the link is clicked.
<a href='seemore.html' onclick="ga ('send', 'event', 'See more', 'click', this.href);">
This captures the link click as an event with the fully qualified url as the label. You can then see these events in the Events reports.

If the see more target is another page, you can use enhanced link attribution: https://support.google.com/analytics/answer/2558867?hl=en.

Related

How Can I Click This Link Using Watir?

I want to navigate a site using watir. I can't find nor focus on an element to click on it. It's the Next link on top right of this url:
Companies
How can I test that the link exists and can focus on it to click it?
The link HTML is:
<a id="view:_id1:_id258:pager6__Next__lnk" href="#" title="Go to next page:">Next</a>
The identifiable attributes seem to be the id (being careful of the auto-generated portions) or the title. The link could be located by either:
browser.link(title: 'Go to next page:') # using title
browser.link(id: /Next__lnk/) # using partial id
You can check if the link is available by checking if it is present:
browser.link(title: 'Go to next page:').present?
You can click with:
browser.link(title: 'Go to next page:').click

Linking to an anchor/id located in another page

I'm trying trying to link to specific sections of the page below using the ID anchor tags. You can see they work when you're on this page: http://lastergroup.com/epe/epe19-240/dev/education.html, but when you navigate to other pages of this site, and click on any of the links on that dropdown menu, none work. What am I doing wrong? I have my IDs and links in place:
<div id="solarenergy">
Solar Energy
I found what was happening. After some research I learned that I have to use the anchor right before the div section I want to link to:
<a name="div1"></a>
Link

How to find link in a row in a table and then click on another link in same row

I am trying to click link in a row, which has another link that has name variable o.customer_id
Basically,I want to click a link "Action" which is in the same row as the link which has customer's id(which is variable)
I have tried using this but has not worked:
find(:xpath, link(have_content(o.customer_id)), :text => 'Action').click
Can someone please help?
Try adding parenthesis after the click to trigger it. I.e. click()
Also open the JavaScript console in your browser and make sure that find return a link element in your page.

HTML Links that do nothing when you are on the page they link to

I am currently building a website containing lots of links to different sections of my website (also known as navigation). Lets call those links and their corresponding pages link1, page1 , link2, page2, link3, page3 etc.
The general code for them is this:
Link1
Link2
Link3
I want the user to click each link to move to the corresponding webpage and it works as supposed to. The problem is that I want the links to do nothing when the user is on the same page as the link they clicked (meaning it will only reload the page). Let me make this clear by using an example:
Current use: User is on page1. User clicks on link1. The browser will reload page1.
Desired use: User is on page1. User clicks on link1. The browser will do nothing.
TL;DR Essentially I am searching for an if clause. I have read there is no if clause in HTML simply because it's a markup language but what is another way to implement this? Thanks for your help.
The best answer I have found without the need to use JQuery or JS after munching through SO is this, answer made by Matt Crinklaw-Vogt:
Add a /#!. This will prevent the scrolling to the top and will also prevent the page reloading.
Code:
Link1
Original answer:
How do I stop a web page from scrolling to the top when a link is clicked that triggers JavaScript?
I'm not sure I like it, but you could use an empty bookmark to do this...
Link1
If you aren't on page1, it will load page1, but once you are there, it won't do anything.
Link2
OR
<a onclick = "return false;">Link2</a>
That cancels out the load.
On page load, you could use JS as follows
Link1
JS:
document.getElementById("link1").setAttribute("href", "#");
You can use javascript to compare the current url to the anchor link, and if they're the same, prevent the default click event. Using jquery:
var url = window.location.pathname,
urlRegExp = new RegExp(url.replace(/\/$/,'') + "$");
$('a').each(function(){
if(urlRegExp.test(this.href.replace(/\/$/,''))) {
$(this).click(function(event) {
event.preventDefault();
});
}
});

Twitter counter display random number

I've just added the Twitter button on my blog under each post, but the tweets number displayed is the same on each button and is random.
In addition to this, if I enter to a post the number displayed change :S
Any idea about this issue?
EDIT:
This is the code that I'm actually using for the Twitter button
<a class='twitter-share-button' data-count='horizontal'data-lang='it'
data-via='ZOMBIEKB' expr:data-text='data:post.title'
expr:data-url='data:post.url' href='https://twitter.com/share'>Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)
[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=&
quot;//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore
(js,fjs);}}(document,"script","twitter-wjs");</script>
Each widgets data-url has to point to the url of the post it is describing not yout blog url:
yes: data-url="http://www.zombiekb.com/url-to-this-post/"
no: data-url="http://www.zombiekb.com/"

Resources