Skip to content
This repository has been archived by the owner on Jan 25, 2021. It is now read-only.

Commit

Permalink
improve/complete tracking of external urls. remove tracking of language.
Browse files Browse the repository at this point in the history
  • Loading branch information
edelm committed Jan 30, 2018
1 parent 405f88e commit dbe512f
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 22 deletions.
1 change: 1 addition & 0 deletions themes/sbvfrd/js/swissbib/Holdings.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ swissbib.Holdings = {
height = height || 760;

window.open(url, 'mappopup', 'height=' + height + ',width=' + width).focus();
swissbib.trackLink(url);
},


Expand Down
9 changes: 9 additions & 0 deletions themes/sbvfrd/js/swissbib/swissbib.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,15 @@ var swissbib = {
//delete it when we have implemented a correct response
return false;

}),

trackLink: (function (url) {
$.ajax({
type: "HEAD",
async: true,
data: "trackUrl=" + url,
url: window.location
});
})

};
Expand Down
2 changes: 1 addition & 1 deletion themes/sbvfrd/templates/Holdings/holding-actions.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if (count($actions) > 0):

<li class="<?=$action['class']?>">
<a href="<?=$action['href']?>" <?php if(isset($action['target'])): ?>target="<?=$action['target']?>"<?php endif; ?> title="<?=$this->escapeHtml($action['label'])?>"
<?php if($action['class'] === 'sign_in'): ?> data-lightbox-ignore <?php endif; ?>>
<?php if($action['class'] === 'sign_in'): ?> data-lightbox-ignore <?php endif; ?> onclick="swissbib.trackLink('<?= $this->escapeHtml($action['href']) ?>')">
<span><?=$this->escapeHtml($action['label'])?></span>
</a>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ if(preg_match('/[\s\S]*<ul[\s\S]*<\/ul>[\s\S]*/', $holdingActionString)): ?>
<?=$mapLink?>
<?php if (isset($holding['institutionUrl']) && !empty($holding['institutionUrl'])): ?>
<?php $wrappedURL = $this->redirectProtocolWrapper()->getWrappedURL($holding['institutionUrl']) ?>
<a href="<?= $this->escapeHtml($wrappedURL) ?>" target="_blank" title="<?=$this->transEsc('Library_Information')?>"> <i class="fa fa-info-circle"></i></a>
<a href="<?= $this->escapeHtml($wrappedURL) ?>" target="_blank" title="<?=$this->transEsc('Library_Information')?>" onclick="swissbib.trackLink('<?=$this->escapeHtml($wrappedURL)?>')"> <i class="fa fa-info-circle"></i></a>
<?php endif; ?>
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion themes/sbvfrd/templates/Holdings/holding-holding.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ if (!empty($holding['opac_note'])) {
<?=$mapLink?>
<?php if (isset($holding['institutionUrl']) && !empty($holding['institutionUrl'])): ?>
<?php $wrappedURL = $this->redirectProtocolWrapper()->getWrappedURL($holding['institutionUrl']) ?>
<a href="<?= $this->escapeHtml($wrappedURL) ?>" target="_blank" title="<?=$this->transEsc('Library_Information')?>"> <i class="fa fa-info-circle"></i></a>
<a href="<?= $this->escapeHtml($wrappedURL) ?>" target="_blank" title="<?=$this->transEsc('Library_Information')?>" onclick="swissbib.trackLink('<?=$this->escapeHtml($wrappedURL)?>')"> <i class="fa fa-info-circle"></i></a>
<?php endif; ?>
</td>
<td><?=$this->escapeHtml($holding['signature'])?></td>
Expand Down
6 changes: 3 additions & 3 deletions themes/sbvfrd/templates/Holdings/holding-item-flipped.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if (preg_match('/[\s\S]*<ul[\s\S]*<\/ul>[\s\S]*/', $holdingActionsContent)): ?>
<?php if ($institution == 'NATIONALLICENCE'): ?>
<?php $nlUrl = $this->nationalLicences()->getUrl($driver)['url']; ?>
<?php $wrappedURL = $this->redirectProtocolWrapper()->getWrappedURL($nlUrl) ?>
<a href="<?= $this->escapeHtml($wrappedURL) ?>" target="_blank" title="<?=$this->transEsc('Library_Information')?>">Get it Online</a>
<a href="<?= $this->escapeHtml($wrappedURL) ?>" target="_blank" title="<?=$this->transEsc('Library_Information')?>" onclick="swissbib.trackLink('<?=$this->escapeHtml($wrappedURL)?>')">Get it Online</a>
<?php else: ?>
<?= $holdingActionsContent ?>
<?php endif; ?>
Expand All @@ -46,7 +46,7 @@ if (preg_match('/[\s\S]*<ul[\s\S]*<\/ul>[\s\S]*/', $holdingActionsContent)): ?>
<td><?= $this->availabilityInfo($item['availability']) ?>
<? if (($item['network'] === 'IDSBB') && (isset($item['holding_status']) | isset($item['process_status'])) && (($item['holding_status'] === '55') | ($item['process_status'] === 'ES'))): ?>
<? $addressURL = $this->redirectProtocolWrapper()->getWrappedURL('http://aleph.unibas.ch/F/?func=item-loan&adm_library=DSV51&doc_number='. $item['localid'] . '&item_sequence='. $item['sequencenumber']); ?>
<a href="<?= $this->escapeHtml($addressURL)?>" target="_blank" title="<?= $this->transEsc('Address') ?>"><?= $this->transEsc('Address') ?></a>
<a href="<?= $this->escapeHtml($addressURL)?>" target="_blank" title="<?= $this->transEsc('Address') ?>" onclick="swissbib.trackLink('<?=$this->escapeHtml($addressURL)?>')"><?= $this->transEsc('Address') ?></a>
<? endif; ?>
</td>
</tr>
Expand All @@ -57,7 +57,7 @@ if (preg_match('/[\s\S]*<ul[\s\S]*<\/ul>[\s\S]*/', $holdingActionsContent)): ?>
<?= $mapLink ?>
<?php if (isset($item['institutionUrl'])): ?>
<?php $wrappedURL = $this->redirectProtocolWrapper()->getWrappedURL($item['institutionUrl']) ?>
<a href="<?= $this->escapeHtml($wrappedURL) ?>" target="_blank" title="<?=$this->transEsc('Library_Information')?>" data-lightbox-ignore> <i class="fa fa-info-circle"></i></a>
<a href="<?= $this->escapeHtml($wrappedURL) ?>" target="_blank" title="<?=$this->transEsc('Library_Information')?>" data-lightbox-ignore onclick="swissbib.trackLink('<?=$this->escapeHtml($wrappedURL)?>')"> <i class="fa fa-info-circle"></i></a>
<?php endif; ?>
</td>
</tr>
Expand Down
6 changes: 3 additions & 3 deletions themes/sbvfrd/templates/Holdings/holding-item.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if (isset($item['locationMap']) && $item['locationMap']) {
<?php if ($institution == 'NATIONALLICENCE'): ?>
<?php $nlUrl = $this->nationalLicences()->getUrl($driver)['url']; ?>
<?php $wrappedURL = $this->redirectProtocolWrapper()->getWrappedURL($nlUrl) ?>
<a href="<?= $this->escapeHtml($wrappedURL) ?>" target="_blank" title="<?=$this->transEsc('Library_Information')?>">Get it Online</a>
<a href="<?= $this->escapeHtml($wrappedURL) ?>" target="_blank" title="<?=$this->transEsc('Library_Information')?>" onclick="swissbib.trackLink('<?=$this->escapeHtml($wrappedURL)?>')">Get it Online</a>
<?php else: ?>
<?= $this->holdingActions($item, 'holdingActionsItem', $record) ?>
<?php endif; ?>
Expand All @@ -37,7 +37,7 @@ if (isset($item['locationMap']) && $item['locationMap']) {
<?= $this->availabilityInfo($item['availability'], $institution) ?>
<? if (($item['network'] === 'IDSBB') && (isset($item['holding_status']) | isset($item['process_status'])) && (($item['holding_status'] === '55') | ($item['process_status'] === 'ES'))): ?>
<? $addressURL = $this->redirectProtocolWrapper()->getWrappedURL('http://aleph.unibas.ch/F/?func=item-loan&adm_library=DSV51&doc_number='. $item['localid'] . '&item_sequence='. $item['sequencenumber']); ?>
<a href="<?= $this->escapeHtml($addressURL)?>" target="_blank" title="<?= $this->transEsc('Address') ?>"><?= $this->transEsc('Address') ?></a>
<a href="<?= $this->escapeHtml($addressURL)?>" target="_blank" title="<?= $this->transEsc('Address') ?>" onclick="swissbib.trackLink('<?=$this->escapeHtml($addressURL)?>')"><?= $this->transEsc('Address') ?></a>
<? endif; ?>
<? endif; ?>
</td>
Expand All @@ -46,7 +46,7 @@ if (isset($item['locationMap']) && $item['locationMap']) {
<?= $mapLink ?>
<?php if (isset($item['institutionUrl'])): ?>
<?php $wrappedURL = $this->redirectProtocolWrapper()->getWrappedURL($item['institutionUrl']) ?>
<a href="<?= $this->escapeHtml($wrappedURL) ?>" target="_blank" title="<?=$this->transEsc('Library_Information')?>" data-lightbox-ignore> <i class="fa fa-info-circle"></i></a>
<a href="<?= $this->escapeHtml($wrappedURL) ?>" target="_blank" title="<?=$this->transEsc('Library_Information')?>" data-lightbox-ignore onclick="swissbib.trackLink('<?=$this->escapeHtml($wrappedURL)?>')"> <i class="fa fa-info-circle"></i></a>
<?php endif; ?>
</td>
<td><?= $this->escapeHtml($item['signature']) ?></td>
Expand Down
19 changes: 6 additions & 13 deletions themes/sbvfrd/templates/layout/layout.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -151,40 +151,33 @@ if (!isset($this->layout()->searchbox)) {
<script type="text/javascript">
$(document).ready(function()
{
function trackLink(url)
{
console.log("-HEAD to " + url);
//TODO: check if HEAD request is executed properly, evtl add sessionId as well
$.ajax({
type: "HEAD",
async: true,
data: "trackUrl=" + url,
url: window.location
});
}

/**
* fügt den GET parameter key=val zu einer url hinzu.
* respektiert evtl bereits vorhandene weitere parameter und '#'
*/
/*
function setParam(uri, key, val) {
return uri
.replace(RegExp("([?&]"+key+"(?=[=&#]|$)[^#&]*|(?=#|$))"),
"&"+key+"="+encodeURIComponent(val))
.replace(/^([^?&]+)&/, "$1?");
}
*/

// alle externen links;
$("a[href^='http']").not("a[href*='//<?=$_SERVER['HTTP_HOST']?>']").each(function(){
$(this).on("click",function(){trackLink($(this).attr('href'));});
$(this).on("click",function(){swissbib.trackLink($(this).attr('href'));});
});

/*
// alle internen links;
$("a[href^='/'],a[href*='//<?=$_SERVER['HTTP_HOST']?>']").each(function(){
var href = setParam($(this).attr("href"), 'trackLang', '<?=$this->layout()->userLang?>');
$(this).attr("href", href);
});
*/

});
</script>

</html>

0 comments on commit dbe512f

Please sign in to comment.