Skip to content

Instantly share code, notes, and snippets.

@yratof
Last active May 7, 2016 18:52
Show Gist options
  • Save yratof/ce7f8b5a2185615b25f2fa10bde52a1d to your computer and use it in GitHub Desktop.
Save yratof/ce7f8b5a2185615b25f2fa10bde52a1d to your computer and use it in GitHub Desktop.
C.H.I.P to GA
# Google analytics on the C.H.I.P
# Importing GPIO pins
import urllib2
import CHIP_IO.GPIO as io
pir_pin = "CSID0"
io.setup(pir_pin, io.IN)
def hitGA():
print("Sent to GA")
urllib2.urlopen("http://www.google-analytics.com/collect?v=1&t=event&tid=UA-77431317-1&cid=1111&ec=Movement&ea=kitchen&el=home").close
while True:
if io.input(pir_pin):
hitGA()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment