三生石@ 2016-09-29 17:12 采纳率: 100%
浏览 23

Shopify点击计数器

I'm trying to make a simple click counter on my shopify page for all the clients/customers to be able to see.

  var a = []; // array of indexes
  var num_clicks = []; // stored number of clicks for each collection

  // Get titles of each collection to use as index
  a[0] = {{linklists[page.handle].links[0].title| json}};
  a[1] = {{linklists[page.handle].links[1].title| json}};
  a[2] = {{linklists[page.handle].links[2].title| json}};
  a[3] = {{linklists[page.handle].links[3].title| json}};
  a[4] = {{linklists[page.handle].links[4].title| json}};
  a[5] = {{linklists[page.handle].links[5].title| json}};
  a[6] = {{linklists[page.handle].links[6].title| json}};
  a[7] = {{linklists[page.handle].links[7].title| json}};
  a[8] = {{linklists[page.handle].links[8].title| json}};

  // Set all number of clicks to 0
  for(var i=0;i<9;i++){
    num_clicks[a[i]] = 0;
  }

  // counter
  function fn(clicked){
    var target; // some target number 
    var x; // div id where I'm putting the counter
    if(num_clicks[clicked] < min_click-1){
      num_clicks[clicked] += 1;
      document.getElementById(x).innerHTML = num_clicks[clicked]+" / " + target;
    } else{
      num_clicks[clicked] += 1;
      document.getElementById(x).innerHTML = num_clicks[clicked] +" / " + target;
      document.getElementById(clicked).href = "SOME LINK";
      return true;
    }
  }

This code works fine and all on one computer but I need it to show the same number "globally" and heard it has to written in server-side. but I can't figure out how to send the counter to the server and retrieve it. if you could help me out with this, it'd be very appreciated.

Thank you all for the help!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题