Bug 4460

Summary: Amazon's AssociateID tag not used in links so referred revenue lost
Product: Koha Reporter: Chris Cormack <chris>
Component: OPACAssignee: Mark Tompsett <mtompset>
Status: CLOSED FIXED QA Contact: Bugs List <koha-bugs>
Severity: normal    
Priority: P3 CC: julian.maurice, katrin.fischer, koha.sekjal, kyle.m.hall, kyle, liz, mtj, mtompset, paul.poulain, reed, veron
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on:    
Bug Blocks: 4463    
Attachments: probably fix for this issue, hard to test fully
Bug 4460 - Amazon's AssociateID tag not used in links so referred revenue lost
Bug 4460 - Amazon's AssociateID tag not used in links so referred revenue lost
Bug 4460 - Amazon's AssociateID tag not used in links so referred revenue lost - Followup
Bug 4460 - Amazon's AssociateID tag not used in links so referred revenue lost - Followup
Bug 4460: Amazon's AssociateID tag not used in links so referred revenue lost
Bug 4460: Amazon's AssociateID tag not used in links so referred revenue lost
Bug 4460: Amazon's AssociateID tag not used in links so referred revenue lost
Error message on Amazon
[SIGNED OFF] Bug 4460: Amazon's AssociateID tag not used in links so referred revenue lost
[SIGNED OFF] Bug 4460: Amazon's AssociateID tag not used in links so referred revenue lost
Bug 4460: Amazon's AssociateID tag not used in links so referred revenue lost

Description Chris Cormack 2010-05-21 01:27:27 UTC


---- Reported by matted-34813@mypacks.net 2010-05-06 14:43:33 ----

Though koha enables usage of Amazon's AssociateID tag, in the enhanced content configuration.  No code currently uses it when generating links to Amazon.  Thus if a person searching the catalog clicks on a link taking them to Amazon for a purchase, Amazon doesn't have the tag and cannot associate the account accordingly.  Thus, any possible revenue is lost.  

Places where the tag might be able to be appended:
- When viewing the item details, the book cover art link might be able to have the tag appended.
- The same might be true for other Amazon related links that koha generates.

See:
http://developer.amazonwebservices.com/connect/entry.jspa?externalID=636
for more info to help integrate.

Usually &tag= with the associate id following it is what is needed, but further investigation will be needed.



--- Bug imported by chris@bigballofwax.co.nz 2010-05-21 01:27 UTC  ---

This bug was previously known as _bug_ 4460 at http://bugs.koha.org/cgi-bin/bugzilla3/show_bug.cgi?id=4460

Actual time not defined. Setting to 0.0
The original reporter of this bug does not have
   an account here. Reassigning to the person who moved
   it here: chris@bigballofwax.co.nz.
   Previous reporter was matted-34813@mypacks.net.
Setting qa contact to the default for this product.
   This bug either had no qa contact or an invalid one.

Comment 1 Reed Wade 2010-05-26 10:30:53 UTC Comment hidden (obsolete)
Comment 2 Reed Wade 2010-05-26 10:36:06 UTC
Patch add tag value to the Amazon reader URL. I was unable to find any documentation relating to passing the tag in there. The normal method uses the product page. I suspect it will work. But, needs testing. Worst case is it's merely harmless and doesn't solve the problem of money not changing hands.

I couldn't figure out what "The same might be true for other Amazon related links that koha generates." relates to. I was unable to find a similar Amazon link in the templates. So, nothing done to address that.
Comment 3 Nicole C. Engard 2011-02-16 21:29:28 UTC
Does not apply:



Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all y
Applying bug 4460 : - Amazon's AssociateID tag not used in links so referred revenue lost
error: patch failed: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl:413
error: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl: patch does not apply
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merged C4/Auth.pm
Auto-merged C4/External/Amazon.pm
Auto-merged koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl
CONFLICT (content): Merge conflict in koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl
Auto-merged koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
Auto-merged koha-tmpl/opac-tmpl/prog/en/modules/opac-readingrecord.tmpl
Auto-merged koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tmpl
Failed to merge in the changes.
Patch failed at 0001.
When you have resolved this problem run "git-am -i -3 --resolved".
If you would prefer to skip this patch, instead run "git-am -i -3 --skip".
nengard@debian:~/kohaclone$
Comment 4 Kyle M Hall 2012-06-09 13:19:35 UTC Comment hidden (obsolete)
Comment 5 Jared Camins-Esakov 2012-06-10 13:58:36 UTC Comment hidden (obsolete)
Comment 6 Ian Walls 2012-06-11 13:48:12 UTC
Typos and scoping issues:

Scoping:  global variable is locally scoped:  XISBN.AmazonAssocTag

Typo:  READING>RECOR instead of READING_RECOR

Easy fixes, but Failed QA until such is done.
Comment 7 Kyle M Hall 2012-07-02 12:53:20 UTC Comment hidden (obsolete)
Comment 8 Jared Camins-Esakov 2012-07-07 16:48:34 UTC Comment hidden (obsolete)
Comment 9 Mason James 2012-07-09 20:42:09 UTC
(In reply to comment #8)
> Created attachment 10686 [details] [review]
> Bug 4460 - Amazon's AssociateID tag not used in links so referred revenue
> lost - Followup
> 
> Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
> All works properly as far as I can tell.

QA comments...

passing QA, looks good

all templates pass 'prove ./xt/tt_valid.t' test OK
Comment 10 Paul Poulain 2012-07-10 08:59:52 UTC
I can't test the patch (no AmazonAssocTag), but it looks correct
Comment 11 Chris Cormack 2012-07-10 20:06:38 UTC
This breaks the opac-user.tt template.

Resulting in an internal server error.
Software error:

Template process failed: file error - parse error - /home/chrisc/git/catalyst-koha/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt line 214: unexpected token (ELSE)
  [% ELSE %] at /home/chrisc/git/catalyst-koha/C4/Templates.pm line 127.


The tests of course pick this up

not ok 672 - /home/chrisc/git/catalyst-koha/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt
#   Failed test '/home/chrisc/git/catalyst-koha/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt'
#   at xt/author/valid-templates.t line 62.
# file error - parse error - /home/chrisc/git/catalyst-koha/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt line 214: unexpected token (ELSE)
#   [% ELSE %]

Which is why we should always run the tests before we push!

This needs to be reverted or a follow up pushed ASAP. OPAC logins currently broken
Comment 12 Paul Poulain 2012-07-12 15:57:42 UTC
(In reply to comment #11)
> This needs to be reverted or a follow up pushed ASAP. OPAC logins currently
> broken

I've reverted the patch on master too, it a bug that is really a BLO for anyone wanting to test/work on OPAC
Comment 13 Mark Tompsett 2015-10-19 22:09:10 UTC
Not only is this failed QA, but a full rewrite is needed to deal with with deprecation of the prog theme.
Comment 14 Katrin Fischer 2015-10-21 05:45:48 UTC
Mark, I think "Failed QA" is a stronger status than "Patch doesn't apply" - which normally just means that a rebase is needed. I'd prefer "Failed QA" in the cases where there were issues with the patch too.
Comment 15 Mark Tompsett 2016-06-21 18:21:36 UTC
Reworking based on output of:
git grep "gp\/reader"
Additionally, some changes might be in order though gp/reader works.
https://affiliate-program.amazon.com/help/topic/t64/a1
suggests using dp
Comment 16 Mark Tompsett 2016-06-21 19:39:26 UTC Comment hidden (obsolete)
Comment 17 Marc Véron 2016-07-26 17:59:49 UTC
I tested and got follwoing results:

Staff client - detail page:

http://www.amazon.com/gp/reader/3257217358?tag=TEST&ref=sib_dp_pt/002-7879865-0184864#reader-link

OPAC:

Detail page:
http://www.amazon.com/dp/3907142330?tag=TEST&

Checked out:
http://www.amazon.com/gp/reader/3907142330?tag=TEST&ref=sib_dp_pt/002-7879865-0184864#reader-link

Reading history:
http://www.amazon.com/gp/reader/3907142330?tag=TEST&ref=sib_dp_pt/002-7879865-0184864#reader-link

Fazit: tag=TEST& added to all links, but on OPAC detail page the reminder of the link is missing.
Comment 18 Mark Tompsett 2016-07-27 03:42:42 UTC
(In reply to Marc Véron from comment #17)
> Fazit: tag=TEST& added to all links, but on OPAC detail page the reminder of
> the link is missing.

Sucky. Will attempt to fix.
Comment 19 Mark Tompsett 2016-08-15 02:44:31 UTC
(In reply to Marc Véron from comment #17)
> I tested and got following results:
> OPAC:
> Detail page:
> http://www.amazon.com/dp/3907142330?tag=TEST&

Missing ref=sib_dp_pt/002-7879865-0184864 is not the issue. The issue is the dangling ampersand. Though if you really think that adding the ref portion is the correct course of action, I could do that. What say you, Marc?
Comment 20 Marc Véron 2016-08-15 07:28:08 UTC
(In reply to M. Tompsett from comment #19)
> (In reply to Marc Véron from comment #17)
> > I tested and got following results:
> > OPAC:
> > Detail page:
> > http://www.amazon.com/dp/3907142330?tag=TEST&
> 
> Missing ref=sib_dp_pt/002-7879865-0184864 is not the issue. The issue is the
> dangling ampersand. Though if you really think that adding the ref portion
> is the correct course of action, I could do that. What say you, Marc?

I did some research, it seems that http://www.amazon.com/dp/3907142330?tag=TEST will be OK. Trailing & is superfluous. It seems to do no harm but can we remove it anyway?
Comment 21 Marc Véron 2016-08-23 07:20:44 UTC
(In reply to Marc Véron from comment #20)
> (In reply to M. Tompsett from comment #19)
> > (In reply to Marc Véron from comment #17)
> > > I tested and got following results:
> > > OPAC:
> > > Detail page:
> > > http://www.amazon.com/dp/3907142330?tag=TEST&
> > 
> > Missing ref=sib_dp_pt/002-7879865-0184864 is not the issue. The issue is the
> > dangling ampersand. Though if you really think that adding the ref portion
> > is the correct course of action, I could do that. What say you, Marc?
> 
> I did some research, it seems that
> http://www.amazon.com/dp/3907142330?tag=TEST will be OK. Trailing & is
> superfluous. It seems to do no harm but can we remove it anyway?

Re-tested with full test plan. Dangling ampersand does no harm.
Will sign off.
Comment 22 Marc Véron 2016-08-23 07:21:32 UTC
Created attachment 54746 [details] [review]
Bug 4460: Amazon's AssociateID tag not used in links so referred revenue lost

Reworking based on output of:
git grep "gp\/reader"
Additionally, some changes might be in order though gp/reader works.
https://affiliate-program.amazon.com/help/topic/t64/a1
suggests using dp
A dp was discovered, so that part of the URL was left unchanged.
The "/ref..." part was changed to "?tag={AAT}&ref..."

TEST PLAN
---------
 1) Added:
     "100 years of Canadian foreign policy /
      edited by Robert Bothwell and Jean Daudelin."
 2) Added a second book with the word foreign in the title.
 3) Waited for reindex
 4) Checked out the Canadian foreign policy book.
 5) Applied patch
 6) Made sure that:
    - AmazonAssocTag was set to TEST (easy to notice)
    - AmazonCoverImages was set to 'Show'
    - OPACAmazonCoverImages was set to 'Show'
 7) Searched intranet for 'foreign' to find the detail page
    -- hovering over picture shows URL with ?tag=TEST& in it.
 8) Went to the OPAC Detail page
 9) Toggling OPACURLOpenInNewWindow, confirmed that URL for
    the picture contained ?tag=TEST& in it.
10) Logged into the OPAC
11) Confirmed the URL in the checked out list on your summary
    page contained ?tag=TEST& in it.
12) Confirmed the URL in the checked out list on your reading
    history page contained ?tag=TEST& in it.
13) Confirmed links worked (went to expected page)
14) run koha qa test tools

Followed test plan. Works as expected.
Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Marc Véron <veron@veron.ch>
Comment 23 Katrin Fischer 2016-08-24 22:35:04 UTC
I am not a real fan of the dangling '&' - instead of fixing it, does someone know of the ref parameter is required? It appears to be hardcoded to ref=sib_dp_pt/002-7879865-0184864, but links also appear to work without it?
Comment 24 Katrin Fischer 2016-08-24 22:57:22 UTC
It looks like Reed Wade removed the ref parameter in the first attempt to fix this bug:
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=10024

Wasn't able to find out when and why it was added.
Comment 25 Katrin Fischer 2016-08-24 23:01:53 UTC
I ended up way back... where no bug numbers and explanations exist.
Comment 26 Katrin Fischer 2016-08-25 20:35:58 UTC
I searched for documentation up and down last night - didn't come up with much. 

We don't have a 'please give feedback' status - so I am setting 'Failed QA', please take a look and consider/comment.
Comment 27 Mark Tompsett 2016-08-25 21:43:10 UTC
(In reply to Katrin Fischer from comment #26)
> I searched for documentation up and down last night - didn't come up with
> much. 
> 
> We don't have a 'please give feedback' status - so I am setting 'Failed QA',
> please take a look and consider/comment.

My guess, and I'm assuming Amazon would be able to tell us, is that ref=... means that is the page it came from. In terms of generating revenue, I'm guessing that not just the tag but the ref is also paid. Only Amazon would know. And their documentation is not easily searched through.
Comment 28 Katrin Fischer 2016-08-26 05:28:46 UTC
I am not persuaded that the ref is really an important part - and if you are paid by it it would be interesting to know what our hardcoded value means.

No mention of the ref parameter:
https://affiliate-program.amazon.com/help/operating/linking
https://affiliate-program.amazon.com/help/topic/t64/a1
Comment 29 Mark Tompsett 2016-11-21 17:57:33 UTC
So, Katrin, how are we fixing this?
Comment 30 Katrin Fischer 2016-11-21 18:01:24 UTC
My research suggests that the ref parameter is not needed - we could remove it and that would also solve the dangling & problem.
Comment 31 Mark Tompsett 2016-11-21 19:00:35 UTC
Created attachment 57688 [details] [review]
Bug 4460: Amazon's AssociateID tag not used in links so referred revenue lost

Reworking based on output of:
git grep "gp\/reader"
Additionally, some changes might be in order though gp/reader works.
https://affiliate-program.amazon.com/help/topic/t64/a1
suggests using dp
A dp was discovered, so that part of the URL was left unchanged.
The "/ref..." part was changed to just an Amazon tag ("?tag={AAT}")
if defined.

TEST PLAN
---------
 1) Added:
     "100 years of Canadian foreign policy /
      edited by Robert Bothwell and Jean Daudelin."
 2) Added a second book with the word foreign in the title.
 3) Waited for reindex
 4) Checked out the Canadian foreign policy book.
 5) Applied patch
 6) Made sure that:
    - AmazonAssocTag was set to TEST (easy to notice)
    - AmazonCoverImages was set to 'Show'
    - OPACAmazonCoverImages was set to 'Show'
 7) Searched intranet for 'foreign' to find the detail page
    -- hovering over picture shows URL with ?tag=TEST in it.
 8) Went to the OPAC Detail page
 9) Toggling OPACURLOpenInNewWindow, confirmed that URL for
    the picture contained ?tag=TEST in it.
10) Logged into the OPAC
11) Confirmed the URL in the checked out list on your summary
    page contained ?tag=TEST in it.
12) Confirmed the URL in the checked out list on your reading
    history page contained ?tag=TEST in it.
13) Confirmed links worked (went to expected page)
14) run koha qa test tools

Followed test plan. Works as expected.
Signed-off-by: Marc Véron <veron@veron.ch>
Comment 32 Mark Tompsett 2016-11-21 19:01:30 UTC
I put this to "Needs Signoff" in case, Marc should retest it.
Comment 33 Marc Véron 2017-02-11 09:06:19 UTC
Created attachment 60127 [details]
Error message on Amazon

I tested some weeks ago and now again, the link to Amazon leads to an error message (see screenshot).
Tested from Intranet detail page with "100 years of Canadian foreign policy / edited by Robert Bothwell and Jean Daudelin."
Link to Amazon is:
https://www.amazon.com/gp/reader/0773534342?tag=TEST#reader-link
Comment 34 Katrin Fischer 2017-05-01 15:13:02 UTC
Created attachment 62921 [details] [review]
[SIGNED OFF] Bug 4460: Amazon's AssociateID tag not used in links so referred revenue lost

Reworking based on output of:
git grep "gp\/reader"
Additionally, some changes might be in order though gp/reader works.
https://affiliate-program.amazon.com/help/topic/t64/a1
suggests using dp
A dp was discovered, so that part of the URL was left unchanged.
The "/ref..." part was changed to just an Amazon tag ("?tag={AAT}")
if defined.

TEST PLAN
---------
 1) Added:
     "100 years of Canadian foreign policy /
      edited by Robert Bothwell and Jean Daudelin."
 2) Added a second book with the word foreign in the title.
 3) Waited for reindex
 4) Checked out the Canadian foreign policy book.
 5) Applied patch
 6) Made sure that:
    - AmazonAssocTag was set to TEST (easy to notice)
    - AmazonCoverImages was set to 'Show'
    - OPACAmazonCoverImages was set to 'Show'
 7) Searched intranet for 'foreign' to find the detail page
    -- hovering over picture shows URL with ?tag=TEST in it.
 8) Went to the OPAC Detail page
 9) Toggling OPACURLOpenInNewWindow, confirmed that URL for
    the picture contained ?tag=TEST in it.
10) Logged into the OPAC
11) Confirmed the URL in the checked out list on your summary
    page contained ?tag=TEST in it.
12) Confirmed the URL in the checked out list on your reading
    history page contained ?tag=TEST in it.
13) Confirmed links worked (went to expected page)
14) run koha qa test tools

Followed test plan. Works as expected.
Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Katrin Fischer  <katrin.fischer@web.de>
Comment 35 Katrin Fischer 2017-05-01 15:16:29 UTC
Created attachment 62922 [details] [review]
[SIGNED OFF] Bug 4460: Amazon's AssociateID tag not used in links so referred revenue lost

Reworking based on output of:
git grep "gp\/reader"
Additionally, some changes might be in order though gp/reader works.
https://affiliate-program.amazon.com/help/topic/t64/a1
suggests using dp
A dp was discovered, so that part of the URL was left unchanged.
The "/ref..." part was changed to just an Amazon tag ("?tag={AAT}")
if defined.

TEST PLAN
---------
 1) Added:
     "100 years of Canadian foreign policy /
      edited by Robert Bothwell and Jean Daudelin."
 2) Added a second book with the word foreign in the title.
 3) Waited for reindex
 4) Checked out the Canadian foreign policy book.
 5) Applied patch
 6) Made sure that:
    - AmazonAssocTag was set to TEST (easy to notice)
    - AmazonCoverImages was set to 'Show'
    - OPACAmazonCoverImages was set to 'Show'
 7) Searched intranet for 'foreign' to find the detail page
    -- hovering over picture shows URL with ?tag=TEST in it.
 8) Went to the OPAC Detail page
 9) Toggling OPACURLOpenInNewWindow, confirmed that URL for
    the picture contained ?tag=TEST in it.
10) Logged into the OPAC
11) Confirmed the URL in the checked out list on your summary
    page contained ?tag=TEST in it.
12) Confirmed the URL in the checked out list on your reading
    history page contained ?tag=TEST in it.
13) Confirmed links worked (went to expected page)
14) run koha qa test tools

Followed test plan. Works as expected.
Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Katrin Fischer  <katrin.fischer.83@web.de>
Comment 36 Katrin Fischer 2017-05-01 15:16:59 UTC
(In reply to Marc Véron from comment #33)
> Created attachment 60127 [details]
> Error message on Amazon
> 
> I tested some weeks ago and now again, the link to Amazon leads to an error
> message (see screenshot).
> Tested from Intranet detail page with "100 years of Canadian foreign policy
> / edited by Robert Bothwell and Jean Daudelin."
> Link to Amazon is:
> https://www.amazon.com/gp/reader/0773534342?tag=TEST#reader-link


Hm, I see the same problem without this patch as well - I think Amazon might have changed something.

To me this appears to happen, when we have #reader-link attached and there is no 'reader link' (preview feature) available for the article on Amazon.
Something else I noticed is that we open the Amazon page in the same tab, for external sources, it's better to always open in a new tab. 

Should we take those 2 issues to a new bug? 

I've signed off on those patches for fixing the problem with the AssociateID.
Comment 37 Nick Clemens 2017-05-10 10:22:57 UTC
Created attachment 63328 [details] [review]
Bug 4460: Amazon's AssociateID tag not used in links so referred revenue lost

Reworking based on output of:
git grep "gp\/reader"
Additionally, some changes might be in order though gp/reader works.
https://affiliate-program.amazon.com/help/topic/t64/a1
suggests using dp
A dp was discovered, so that part of the URL was left unchanged.
The "/ref..." part was changed to just an Amazon tag ("?tag={AAT}")
if defined.

TEST PLAN
---------
 1) Added:
     "100 years of Canadian foreign policy /
      edited by Robert Bothwell and Jean Daudelin."
 2) Added a second book with the word foreign in the title.
 3) Waited for reindex
 4) Checked out the Canadian foreign policy book.
 5) Applied patch
 6) Made sure that:
    - AmazonAssocTag was set to TEST (easy to notice)
    - AmazonCoverImages was set to 'Show'
    - OPACAmazonCoverImages was set to 'Show'
 7) Searched intranet for 'foreign' to find the detail page
    -- hovering over picture shows URL with ?tag=TEST in it.
 8) Went to the OPAC Detail page
 9) Toggling OPACURLOpenInNewWindow, confirmed that URL for
    the picture contained ?tag=TEST in it.
10) Logged into the OPAC
11) Confirmed the URL in the checked out list on your summary
    page contained ?tag=TEST in it.
12) Confirmed the URL in the checked out list on your reading
    history page contained ?tag=TEST in it.
13) Confirmed links worked (went to expected page)
14) run koha qa test tools

Followed test plan. Works as expected.
Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Katrin Fischer  <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 38 Kyle M Hall 2017-05-12 12:51:57 UTC
Pushed to master for 17.05, thanks Mark!
Comment 39 Katrin Fischer 2017-05-14 09:52:21 UTC
This patch has been pushed to 16.11.x and will be in 16.11.08.

Always glad to see this 4 digit bug numbers resolved.
Comment 40 Julian Maurice 2017-05-22 10:39:56 UTC
Pushed to 3.22.x for 3.22.21
Comment 41 Mason James 2017-05-24 02:35:19 UTC
Pushed to 16.05.x, for 16.05.13 release