Last active
May 7, 2016 18:52
-
-
Save yratof/ce7f8b5a2185615b25f2fa10bde52a1d to your computer and use it in GitHub Desktop.
C.H.I.P to GA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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