Simple Javascript SDK Tutorial – Reward Enable Your Website

We have had a lot of interest about our new Javascript SDK and thought we’d write a quick tutorial to get things going. Here is a list of examples showing how you can use the JS SDK to reward enable common elements on your website:

1. Reward-enable a form (or button):

If you want to reward enable a form you can attach an earning event to the “onClick” event of the button in the form:

<form>
  ...
  <button onClick='_ptq.push(["invite",{"points":10}]);'>
      submit
  </button>
</form>

DEMO – Click the invite button below and earn 10 points:

2. Reward-enable a download link (or any link):

Attach the earning event to the “onClick” event of the download link:

<a
    href="/a-really-interesting-file.pdf.zip"
    onClick='_ptq.push(["download",{"points":10}]);'>
    Download
</a>

DEMO – Download the file below and earn 10 points:

Download

3. Reward-enable a page load:

If you want to reward enable the viewing of a page, you can attach the earning event to the “onLoad” event of the body tag.

<body onload='_ptq.push(["view",{"points":10}]);'>...</body>

DEMO – View this sample page and earn 10 points.

I hope this helps you get going and shows how to attach points to different kinds of events. You can always reach us at api@punchtab.com if you have further questions.

72 Comments

  1. This, tied in with custom rewards, actually is giving me a pretty good idea.. Now if only I could make more free time in the day!

    • Ranjith Kumaran

      Stuart, let us know if we can help (well, apart from making more free time in the day). We’d love to learn from what you’re up to.

      • Can you enable a form so that a user can only get points from submitting the form ONCE? For example, I may offer points to have people sign up for newsletter but don’t want them to keep coming back every day and trying to subscribe just to get extra points.

        Thanks

        • mehdi (Author)

          I would then suggest to read to call the JS SDK after validating this data on your side.

          • Thanks for responding. Can you explain a littlemore about what you mean by this so that I can do a littlemore research to figure out howto do this?

            Thanks

          • mehdi (Author)

            Brian, please contact us at support@punchtab.com for more details.

  2. howdy, very good page, and a decent understand! at least one for my favorites.

  3. Vilash Varghese

    hi
    I have installed punchtab in my drupal site http://www.krazykoder.com but I am finding it to difficult to how to reward users on custom events.Well the basics reward events works well like (facebook like,tweet,first time site visit…)
    So I found a blog of howto install custom events for rewarding user with points..here is the walkthrough i tried to get it started for me:-
    1.)copy-pasted the JS snippet from installation page at the end of body tag.Copy-pasted the sidebar widget code within body tag.
    2.)activated the JS SDK from settings in dashboard of my punchtab account..and created a custom catalog for it(As the default catalog doesnt supports when i have to activate the JS SDK..plz correct me if i am wrong).
    3.)copy pasted the below code to reward my users..if they click the below link..

    click me

    4.)but when a punchtab registered user clicks on this link ..nothing happens..I mean No points are rewarded to that users ..

    so please tell me what wrong step I am taking..and also provide me with correct steps to get it started to my site..
    please help..
    tks

  4. Vilash Varghese

    hi all,
    i have implemented punchtab on my drupal site, it works great for basic events..but for custom events there are lot of confusion for me to implement it. I have enabled the JS SDK from dashboard but when a user clicks on the link

    Download
    ,nothing happens.
    Also i have called the ” _ptq.push(["invite",{"points":10}]);” in the script tag of html file..so the user gets rewarded vd 10 points when they visit the same html page for the first time..afterwards nothing happens..so how can I use this function to reward my users as soon as the user posts some content on my site..
    Also one more doubt is when i am enabling this custom JS SDK ,I wont be able to use the default catalog that punch tab provides.
    Please help me to solve my queries.
    tks in adv
    Vilask

  5. Could any one tell me exactly where to add the above codes in the install snipper we got?

  6. rus

    testing

  7. Adil

    that great…

  8. sym

    nice

  9. sym

    good

  10. Adil Farooq

    nice…

  11. I am trying to put this everywhere on my site

    And neither the tab or activity shows up.

    what do I need to do to add the activity/tab so customers can click on the tab?

  12. Awesome already for my website!!!!!

  13. random

    testingg

  14. I want to reward enable some functions on a joomla site (php)
    But php scripting is to hard for me to edit. I’ve tried everything
    What I want to do:
    I have a shoutbox (ajax) and everytime anyone writes in it, they’re awarded points.
    The problem is I can’t figure out where the action is for posting a shout

  15. Amna

    cool

  16. avril

    nice

  17. gowtham

    innovative idea supperb work keep going punchtab….:))

  18. stacy

    cool!

  19. Stavros

    nice!!!

  20. very helpfull

  21. Thx for the options!

  22. wena

  23. Is for each action reward a differnt vode, thats a bit complicated, is there no way to put it in a formula that can be reused.I need code programing skills for this.

    What do i have to do if i want to reward watching a video on a webpage please?

  24. How can i put those reward systems in wordpress ?

  25. Any idea’s on how to embed the code into a mailchimp form?

  26. if i use the wibiya toolbar (which has PunchTab app in it) do i need to put these codes into my site? or does it do it automaticly?

  27. defhead

    awesome

  28. stacy

    great!

  29. kyo

    cool

  30. defhead

    it’s not working on my website :(

  31. oread

    read the FAQ

  32. oread

    how can I put these punchtab flags next to likes and g+’s?

  33. asimo

    testing..

  34. defhead

    yhm

  35. Tony

    awesome!

  36. Tony

    cool stuff!

  37. Adil Farooq

    nice

  38. guest

    awesome!

  39. defhead

    great job

  40. steve

    is there a way to give rewards based off of the dollar amount? for example, can we give 100 pts per dollar spent on our site? so if someone purchased a 5 dollar item off our site, they would gain 500 pts?

    • Fey

      If you go to PunchTab, click on the Loyalty program and then click on Instillation. On the bottom left side of the screen you will see 4 steps. Click on #4 Shopify COnfiguration (I use Shopify so I’m not sure if this is the same steps using a different platform).

      Then on the right is shows:
      Enter Rewards Points for currency unit (example: Dollar) spent

      This allows you to set the amount of points earned for each dollar spent and then click save.

  41. Fey

    I am using Shopify and wanted to use the custom “addtotimeline” option for the loyalty program. I’m not exactly sure what this option does, but I’m hoping that if a custom uses this that it adds a link to http://www.ProjectFey.com and that they can add a comment about the site as well.

    Can someone please tell me EXACTLY what code I need to add and where to add it into the Shopify site that would be great. Also does it need to be entered into a specific ‘line’ as well?

    I’m not savy when it comes to this sort of thing and I’ve been trying for hours without success.

  42. guest

    great!

  43. guest

    great man! :)

  44. guest

    cool

  45. jiujiujiu

    wow~ nice

  46. guest

    need more points!

  47. guest

    very good! Thank you!

  48. DC Holland

    I need a developer to help me customize/incentivize my punchtab.

  49. Rae Higgins

    Thanks!!

  50. mark

    helful tutorial.

  51. guest

    like it!

  52. guest

    The download link is not working.
    The file is downloaded but no points are awarded. (Win7/Chrome)

  53. guest

    The download link is not working.
    The file is downloaded but no points are awarded.

  54. guest

    like it again!

  55. Kwilt

    Thanks.

  56. guestb

    Thanks!

  57. How can we enable the JS SDK enabled reward actions on a Joomla based website?

  58. guestb

    thenk you!

  59. stacy

    great thank you

  60. Praveen Vishnu Shamain

    Thank you.

  61. guestb

    thanks!!!

  62. guestb

    very nice! thanks!!!

  63. guestb

    thank you very much!

  64. duha

    cool……….

  65. So with this I could reward a certain number of points for a person viewing an entire video?

Trackbacks for this post

  1. Biz Dev for Engineers | PunchTab:Blog

Leave a Reply